A CLAUDE.md is the briefing Claude Code reads at the start of every session in your project. For a Flutter app it answers the questions you would otherwise answer again each time: how to run the checks, how the code is laid out, and what never to touch. This post gives you a template, then explains what belongs in it and what does not.
What Claude Code does with it
The facts, from Claude Code’s memory documentation, read on the day this post was written:
- CLAUDE.md files are “markdown files that give Claude persistent instructions for a project, your personal workflow, or your entire organization.”
- Claude Code loads the file from your working directory and every directory above it. A file in a subdirectory loads when Claude works with files there.
/initgenerates a starting file. If one exists it suggests improvements instead of overwriting it.- A file can import another with
@path/to/file, up to four levels deep. - The documentation says to target under 200 lines and to keep it to “facts Claude should hold in every session: build commands, conventions, project layout, ‘always do X’ rules.”
- It also says Claude treats these files “as context. They aren’t enforced configuration.”
That last point shapes everything below. A CLAUDE.md is a strong suggestion, not a lock.
A template for a Flutter app
Copy this and change the names, commands and rules to match your project.
# MyApp (Flutter)
Flutter app for iOS and Android. Feature-first layout, Riverpod for state.
## Commands
- Install: `flutter pub get`
- Generate code: `dart run build_runner build --delete-conflicting-outputs`
- Analyze: `flutter analyze` (must be clean before you say a task is done)
- Test: `flutter test`
- Format: `dart format lib test`
- Run on a device: `flutter run --flavor dev`
## Layout
- `lib/features/<feature>/{data,application,presentation}`
- Features do not import each other's `data/`. Shared code goes in `lib/core/`.
- Repositories wrap SDKs (Firebase, purchases). Widgets never call an SDK directly.
## Rules
- State: Riverpod notifiers with codegen. `ref.watch` in `build`, `ref.read` in callbacks.
- Every async screen handles loading, error and empty states.
- Colors, spacing and type come from the theme tokens. No hard-coded colors or sizes in widgets.
- Never edit `*.g.dart` or `*.freezed.dart`. Change the source and regenerate.
- Do not add a package without asking me first.
- User-facing text goes in the localization files, not in widgets.
## Done means
- `flutter analyze` is clean and `flutter test` passes.
- You ran the app on a device or simulator for UI changes, or you said you could not.
## Decisions
Read `decisions.md` before you change anything it covers.
That is about 30 lines. It leaves a lot of room.
What to put in
Commands, exactly as you run them. This is the highest-value section. If Claude does not know that code generation is a separate step, it will report success on a build that has stale generated files.
The layout and the boundaries. The one-line rules that stop architecture drifting: who may import whom, where SDKs are allowed. MobileKit’s flutter-standards skill uses the same feature-first structure, with repositories wrapping SDKs and notifiers holding state.
A definition of done. “Analyze is clean and tests pass” turns a vague “finished” into something checkable.
Pointers, not copies. If you keep decisions in a file, say where it is. Use an @decisions.md import if you want it loaded every session.
Start from Flutter’s official rules
Flutter publishes an official agent plugin for Claude Code, and its documentation gives two commands: claude plugin marketplace add flutter/agent-plugins, then claude plugin install dart-flutter@dart-flutter. The plugin brings skills and the Dart and Flutter MCP server. The same page says Claude Code plugins “discover skills and MCP servers, but don’t automatically load plugin rules”, and tells you to add the rules you want from the official rules repository to your project’s CLAUDE.md. That is a good way to seed your own file: take the official rules you agree with, then add your project’s commands and layout above them. The Flutter AI setup page has the details, and we read it on the day this post was written.
What to leave out
- Long procedures. The documentation says multi-step procedures belong in a skill or a path-scoped rule. A skill’s body loads only when it is used, while CLAUDE.md loads every time. A 300-line standards document in CLAUDE.md costs you context on every task that has nothing to do with it.
- What the analyzer already enforces. If a lint rule catches it, you do not need a sentence.
- Secrets. Never put keys, tokens or passwords in it. It is a committed file.
- Anything you have not seen go wrong. Add a line when Claude makes the same mistake twice, not before.
When you need more than a suggestion
Because CLAUDE.md is context, it can be ignored on a busy day. For rules that must hold, Claude Code has hooks: commands that run automatically at points in its lifecycle. The hooks documentation lists events such as PreToolUse, which can block a tool call, and PostToolUse, which runs after one succeeds. Formatting after every edit is a good fit:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "f=$(jq -r '.tool_input.file_path') && case \"$f\" in *.dart) dart format \"$f\" ;; esac" }]
}
]
}
}
That goes in .claude/settings.json. The hook receives the event as JSON on its standard input, and this one reads the edited file’s path with jq and formats only Dart files, the same pattern the documentation shows for Prettier. Check the hooks page for the current format before you copy it, because the configuration has more options than this sketch shows. More examples, including protecting generated files, are in Claude Code hooks for Flutter.
Keep it alive
A CLAUDE.md rots. Once a month, read it and delete the lines that are no longer true. When Claude keeps ignoring a line, the line is usually too vague or buried in a long file. Make it shorter or move it into a hook.
Where MobileKit fits
The pack goes beyond a single file: its skills hold the long standards that would bloat a CLAUDE.md, and it records every decision in a file in your repo that the next session reads. The CLAUDE.md stays short and points at them. If you are starting from nothing, the whole route from idea to both stores is in this guide, and how it compares with doing the same work by hand shows what the extra structure buys you.