zulip-flutter
CLAUDE.md487 starsChanged 5 months agoApache-2.0View on GitHub
Zulip Flutter — the official Zulip mobile app for Android and iOS, built with Flutter/Dart. Uses the latest Flutter from Flutter's main channel (not stable/beta). ZulipBinding (abstract, in lib/model/binding.dart) is a singleton that wraps all external services (plugins, platform channels, store creation). Modeled on Flutter's WidgetsFlutterBinding. See @./rules/data-store.md for detailed conventions and architecture for writing state logic. See @./rules/api.md for detailed conventions on writing API bindings. Uses Pigeon for type-safe platform channels (Android intents, notifications). See @./rules/testing.md for detailed conventions…
In this repositoryOne other file it gives its agents.
- fetch-zulip-messagesSkill
The file
We split this CLAUDE.md into the rules it gives an agent
12 rules. About 0 are common, 3 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 70
Stream → channel rename: Use "channel" instead of "stream" for new variable/parameter names (e.g., channelId not streamId).
- Very specific: line 77
Test fixtures: test/example_data.dart has builders for all common data types
- Very specific: line 105
After every edit, run the Flutter analyzer to catch issues early.
- Very specific: line 106
Use this command: flutter analyze --no-pub 2>&1 | head -20
- Distinctive: line 107
When working on an issue, don't try to look at the server/web implementation.
- Very specific: line 119
Don't write comments that restate what the code does ("// The old key is now superseded" on .supersededTimestamp.equals(now)).
- Very specific: line 121
Use comments only for context not obvious from the code itself (e.g., "// A device-update event acks the new key." before a handleEvent …
- Distinctive: line 137
When you encounter a chat.zulip.org narrow URL (in an issue, PR, or user message), use the fetch-zulip-messages skill to read the …
- Very specific: line 157
Never commit that hunk. Take it back out before committing any change to pubspec.yaml, and discard it (git checkout pubspec.yaml) before …
- Very specific: line 198
Run plain git <subcommand> from the repository root instead.
- Very specific: line 209
If the message itself contains a single quote, a single quote can be expressed inside a Bash single-quoted string with the five characters …
- Distinctive: line 223
Leave these uncommitted unless explicitly asked.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project overview
Zulip Flutter — the official Zulip mobile app for Android and iOS, built with Flutter/Dart. Uses the latest Flutter from Flutter's main channel (not stable/beta).
Common commands
# Run unit tests
flutter test --no-pub
# Run a specific test file
flutter test --no-pub test/foo/bar_test.dart
# Run a specific test by name
flutter test --no-pub test/foo/bar_test.dart --name 'some test name'
# Static analysis (type-checking + linting)
flutter analyze --no-pub
# Run all test suites (only changed files vs upstream main)
tools/check
# Regenerate JSON serialization code after editing API types
tools/check --fix build_runner
# Regenerate i18n after editing assets/l10n/app_en.arb
flutter gen-l10nArchitecture
Binding pattern
ZulipBinding (abstract, in lib/model/binding.dart) is a singleton that wraps all external services (plugins, platform channels, store creation). Modeled on Flutter's WidgetsFlutterBinding.
LiveZulipBinding— real implementation used in the appTestZulipBinding(intest/model/binding.dart) — test implementation that fakes all external dependencies
State management
GlobalStore(lib/model/store.dart) — app-wide state (accounts, global settings). Access viaGlobalStoreWidget.of(context).PerAccountStore(lib/model/store.dart) — per-account data (messages, users, channels, unreads, etc.). UsesChangeNotifierfor reactivity.
See @./rules/data-store.md for detailed conventions and architecture for writing state logic.
API layer (lib/api/)
core.dart—ApiConnectionHTTP client with auth, JSON handling, error handlingroute/— one file per API endpoint group; top-level async functions takingApiConnectionas first parammodel/— data types with JSON serialization viajson_serializable; generated.g.dartfiles must be kept up to date
See @./rules/api.md for detailed conventions on writing API bindings.
Platform layer (lib/host/)
Uses Pigeon for type-safe platform channels (Android intents, notifications).
Key conventions
- All API type constructor params are
required, even nullable ones — no default values. Usetest/example_data.dartfor test defaults. - Server compatibility: the minimum supported server version is
kMinAllowedZulipVersioninlib/api/core.dart. UseTODO(server-N)comments for newer features. - Tests use
package:checks(notexpect/matcher). - No
dart format— follow existing code style manually. Auto-format is disabled in VS Code settings. - Prefer relative imports within the package.
- Strict analysis: strict-inference, strict-raw-types, strict-casts are all enabled.
- Stream → channel rename: Use "channel" instead of "stream" for new variable/parameter names (e.g.,
channelIdnotstreamId). The API still uses "stream" in many places, but new code in this codebase should use "channel". See #631.
Testing patterns
- Widget tests:
testWidgets+TestZulipBinding+testBinding.globalStore - API tests:
FakeApiConnectionwithconnection.prepare(json: ...)/connection.takeRequests() - External APIs: wrap in
ZulipBinding, fake in tests - Test fixtures:
test/example_data.darthas builders for all common data types
See @./rules/testing.md for detailed conventions on writing tests.
i18n
New UI strings go in assets/l10n/app_en.arb. Output class is ZulipLocalizations. Run flutter gen-l10n after editing.
Database
Uses Drift ORM with SQLite. Schema changes require running tools/check --fix drift to update versioned schema files and migration helpers.
Design
UI designs come from Figma (linked in issues). Match colors, padding, and font sizes exactly. Use DesignVariables and ContentTheme for theme values.
Debugging test failures
- Full
flutter testtakes ~60s. Capture output to a temp file on the first run; don't re-run the full suite just to find the failure details. - Once the failing test file is identified, re-run just that file (~3-5s).
- For localized failures (one test, one file), read the test and source directly rather than spawning broad codebase searches.
Developing changes
- After every edit, run the Flutter analyzer to catch issues early.
Use this command:
flutter analyze --no-pub 2>&1 | head -20 - When working on an issue, don't try to look at the server/web implementation.
Stick to the issue's spec and the API docs.
Exception: for questions about server behavior that the API docs
don't answer, and for work on API documentation or design itself,
do read the server code, in
../zulipif present. - Code comments often cite zulip-mobile, the legacy React Native app,
by path or commit. Read it in
../zulip-mobileif present.
Writing clear code
- Keep comments minimal.
Don't write comments that restate what the code does
("// The old key is now superseded" on
.supersededTimestamp.equals(now)). Use comments only for context not obvious from the code itself (e.g., "// A device-update event acks the new key." before ahandleEventcall). - Use semantic line breaks in dartdocs. Break lines at natural prose boundaries — commas, end of a clause, end of a sentence — not at a fixed column width. This keeps diffs minimal when dartdocs change: edits to one sentence don't reflow neighboring lines. See: https://github.com/dart-lang/site-shared/blob/3408a7468/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks https://rhodesmill.org/brandon/2012/one-sentence-per-line/
Zulip chat links
- When you encounter a chat.zulip.org narrow URL (in an issue, PR, or user message), use the fetch-zulip-messages skill to read the conversation. Don't use WebFetch; it can't access Zulip message content.
Cloud sessions (Claude Code on the web)
Before running tests on Claude Code on the web, add this to
pubspec.yaml(the proxy blockspackage:sqlite3's prebuilt-library download, anthropics/claude-code#78330):# Cloud-session workaround; do not commit. hooks: user_defines: sqlite3: source: systemNever commit that hunk. Take it back out before committing any change to
pubspec.yaml, and discard it (git checkout pubspec.yaml) before finishing. TODO(upstream): when that issue is fixed, drop this item, the libsqlite3-dev line in tools/provision-cloud, and the bullet in docs/howto/claude-web.md.- Don't commit
pubspec.lockchurn on Claude Code on the web. The cached Flutter SDK drifts off the pin, andflutter pub getrewrites the lockfile to match; that isn't part of your change. Discard it (git checkout pubspec.lock) before committing. - On Claude Code on the web, the GitHub API reaches only the
session's own repo, which is a fork of zulip/zulip-flutter.
So to read issues and PRs on zulip/zulip-flutter itself, or on
any other repo such as flutter/flutter, use the built-in GitHub
search tools with a
repo:qualifier in the query (e.g.repo:zulip/zulip-flutter), or fetch the item's github.com URL with WebFetch. Issue comments are reachable by neither route (PR comments are); when an issue's comment thread matters, ask the user to paste it. (Limitation tracked as anthropics/claude-code#78277.) - Open pull requests only as drafts.
A PR is created on behalf of the user's own GitHub account,
and a session's commits are authored as Claude, with no
responsible human author. A draft says so: it's a handoff,
not a submission. After opening one, tell the user the rest
is theirs — teleport the session (
claude --teleport), revise and take authorship (with--reset-author), and mark the PR ready for review. See docs/howto/claude-web.md ("Trust model").
Using Git
- Use
@instead ofHEAD— there may be a stray file namedHEAD, which causesfatal: ambiguous argument 'HEAD'errors. - Don't use
git -C <path>to operate on this repo — it triggers a permission prompt. Run plaingit <subcommand>from the repository root instead. - Always
git addspecific new files — never usegit add -Aorgit add .. The worktree can pick up stray files. For adding changes to all existing files, usegit add -u. Use plain single-quotes for commit messages — write
git commit -m 'message', not heredoc$(cat <<'EOF'...). Command substitution$(...)triggers a permission prompt.If the message itself contains a single quote, a single quote can be expressed inside a Bash single-quoted string with the five characters
'"'"'.- Use
git cherry-pickfor rewriting history — never usegit rebase -i, as it requires an editor, which triggers permission prompts. Instead, usegit cherry-pick(with--no-commitwhen modifications are needed) to replay commits. - Don't commit files that aren't meant for the repo — reports, reviews, drafts, and other output addressed to the person you're working with rather than to the codebase. Leave these uncommitted unless explicitly asked. This matters most on Claude Code on the web, which pushes commits to GitHub automatically: a committed security review would go public before any human had looked at it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

