Using AI at work

Use CLAUDE.md to Tell Claude Code the Project Rules

Put the run command, data rules, prohibitions, and verification method that were being repeated in every request into the project's CLAUDE.md in a concise form. Distinguish the `/init` function that creates a draft from the purposes of different file locations, and complete a 35-line rules file for the expense CSV example.

Show contents

Who this is forBeginners who repeatedly modify one project with Claude Code and want to reduce the need to explain the same rules in every request

What you need
  • Have expenses.csv and summarize.py in the vibe-expenses folder
  • Know the run command and expected output for the monthly-total tool
  • Understand that CLAUDE.md is project context rather than an enforced configuration

01Move only repeatedly stated rules into the project file

In the previous article, every request to Claude Code explicitly included the input file, the use of the standard library, the prohibition on modifying the original CSV, the run command, and the expected output. If you keep working on the same project, you can put these repeated rules in CLAUDE.md instead of rewriting them every time. Claude Code reads this file at session start and uses it as project context.

However, do not treat CLAUDE.md as an access-control mechanism or an absolute enforcement rule. According to the official documentation, the file provides context, and instructions are easier to follow when they are specific and concise. Therefore, do not assume that it will 'always be followed perfectly'; continue checking the actual changes.

Repeated ruleExample to put in CLAUDE.mdReason
Inputexpenses.csv / UTF-8 / fixed columnsReduce arbitrary assumptions about other files or columns
ImplementationUse only the Python standard libraryMake the package scope explicit
Runpython summarize.py expenses.csvFix the verification command
Do notDo not modify expenses.csvState the requirement to preserve the original data
Completion criterionTwo expected monthly output linesProvide values a person can compare after the task

02Distinguish team-shared, personal-global, and personal-project file locations

The locations described in the official documentation serve different purposes. `./CLAUDE.md` at the project root is suitable for project rules shared with a team. `~/.claude/CLAUDE.md` is a personal note that applies across all of your projects, while `./CLAUDE.local.md` is for personal use in one specific project and can be added to .gitignore.

Prompt
./CLAUDE.md
~/.claude/CLAUDE.md
./CLAUDE.local.md

This example uses `./CLAUDE.md` because it contains information that belongs to the project itself, such as run commands and data rules. Keeping personal preferences or local paths out of a team-shared file makes the project easier to manage.

03Use /init to create a draft, then review it instead of accepting it as-is

When you use `/init` in a session, Claude Code can analyze the codebase and create a draft CLAUDE.md containing build and test commands and project conventions. The official documentation explains that if CLAUDE.md already exists, it does not overwrite it but instead proposes improvements. So `/init` is best treated not as a command that decides project rules automatically, but as a starting point for a draft that a person refines.

Prompt
/init

After a draft is created, check whether it contains commands that do not match the actual project, tests that do not exist, or overly generic instructions. This article did not actually run Claude Code, so it does not fabricate an example response claiming that `/init` generated particular wording.

04Organize a 35-line CLAUDE.md for the expense example

The example below is a CLAUDE.md containing only the rules needed for the fictional project in this series. The official documentation recommends keeping each file under 200 lines; this example stays at 35 lines. The goal, data, Python rules, run command, expected result, and working rules are separated so that a person can understand them immediately as well.

Prompt
# Project: vibe-expenses

## Goal
- Read expenses.csv and summarize expense amounts.
- Keep the example small and understandable for beginners.

## Data
- Input file: expenses.csv
- Encoding: UTF-8
- Columns: date, category, amount
- date format: YYYY-MM-DD
- category values stay in English.
- amount is treated as an integer.

## Python rules
- Use only the Python standard library.
- Prefer csv for reading CSV files.
- Do not add third-party packages.
- Keep functions short and names descriptive.
- Do not modify expenses.csv.

## Commands
- Run: python summarize.py expenses.csv
- On Windows, py summarize.py expenses.csv is also acceptable.

## Expected result
- 2026-09 = 26600
- 2026-10 = 9800

## Working rules
- Explain the planned change before editing files.
- Change only files needed for the requested task.
- Do not invent extra input columns or business rules.
- If a requirement is unclear, ask before expanding scope.
- After editing, show what changed and how to verify it.

Do not put secrets such as passwords, API keys, or real customer paths here. A project instruction file is meant to provide working context, so it is safer to keep it focused on rules that would not cause problems if the file were exposed or shared.

05Prefer verifiable rules over long explanations

A longer CLAUDE.md is not automatically better. Rules that can be checked against actual changes—such as 'do not add external packages,' 'do not modify expenses.csv,' and 'this is the run command'—are more useful than hard-to-judge statements such as 'write good code.' You can use the `@path` syntax to import content from another file when needed, but this small example does not need any additional file imports.

  • List only filenames and commands that actually exist in the project.
  • Do not keep accumulating one-off task instructions in CLAUDE.md.
  • State prohibitions concretely so it is clear what must not be done.
  • Leave expected values or verification commands that can be used to judge completion.
  • Do not put personal secrets or API keys in the project rules file.

Even after adding rules, you still need to check which files Claude Code actually changes. CLAUDE.md does not replace review; it reduces the amount of project context you have to repeat.

06Reread the rules file before the next task

After saving CLAUDE.md, read it once yourself before requesting the next feature. If the current code or run command has changed but old instructions remain, the file can provide the wrong context instead. In particular, update the rules file when expected output or filenames change.

Review questionExpected answer in this exampleSignal that an update is needed
Is the input file correct?expenses.csvA different filename remains
Is the run command correct?python summarize.py expenses.csvAn old script name remains
Is the package rule correct?Use only the standard libraryIt requires an unnecessary external package
Are the expected values correct?26600 / 9800Numbers do not match the current example
Is the prohibited scope clear?Do not modify expenses.csvOnly vague wording is present

In the next article, keep these rules in place but do not implement the new feature immediately. Design it first in plan mode. The goal is to review at the planning stage what changes would be required for a `--by-category` option that outputs food 20500, transport 2900, and supplies 3200 for 2026-09.

What to check yourself

Written using the Claude Code official documentation (checked 2026-09-22) and the fictional example in this series · Claude Code not actually run · No Python code in this article to execute

  • Confirmed against the official documentation the locations and purposes of project `./CLAUDE.md`, personal-global `~/.claude/CLAUDE.md`, and personal-project `./CLAUDE.local.md`
  • Compared with the official documentation the explanation that `/init` analyzes the codebase to create a draft and proposes improvements instead of overwriting an existing CLAUDE.md
  • Confirmed that CLAUDE.md is described as project context rather than an enforced configuration
  • Confirmed that the example CLAUDE.md is 35 lines, within the official recommendation of fewer than 200 lines per file
  • Confirmed that the example rules include the run command, data rules, prohibitions, expected result, and verification workflow
  • Confirmed that the article does not claim to have produced an actual `/init` result or Claude Code response
Verification limits

This article did not actually run Claude Code's `/init` or memory-file features. The CLAUDE.md example is editorial content based on the fictional project requirements in this series; in a real project, a person must review it against the current file structure and commands.