armada
CLAUDE.md2 starsChanged 6 months agoApache-2.0View on GitHub
This file provides guidance to Claude (and other AI coding assistants) for contributing to the Zulip codebase. These guidelines are designed to produce contributions that meet the same high standards we expect from human contributors. Zulip is a team chat application used by thousands of organizations, built to last for many years. It is developed by a vibrant open-source community, with maintainers who have consistently emphasized high standards for codebase readability, code review, commit discipline, debuggability, automated testing, tooling, documentation,…
- Deletes or force-pushes
In this repository5 other files it gives its agents.
- debug-node-coverageSkill
- fetch-zulip-messagesSkill
- fix-backend-coverageSkill
- visual-testSkill
- write-changelogSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
72 rules. About 0 are common, 53 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈53
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 74
Before writing any code, you must understand:
- Distinctive: line 87
Follow this workflow for every task: understand → propose → implement → verify.
- Distinctive: line 91
Before making any changes:
- Distinctive: line 106
Always show existing similar code and explain how it works before proposing changes.
- Distinctive: line 111
Before writing code, explain the plan:
- Very specific: line 135
Never update API_FEATURE_LEVEL manually.
- Distinctive: line 147
Run tests before making a commit.
- Very specific: line 162
Read documentation from docs/, starlight_help/src/content/docs/, and api_docs/.
- Distinctive: line 163
Read existing code in the area you're modifying.
- Distinctive: line 164
Use git grep to find similar patterns in the codebase and read those.
- Distinctive: line 168
Be consistent with existing code: Look at surrounding code and follow the same patterns, as this is a thoughtfully crafted codebase.
- Distinctive: line 173
Keep everything well factored for maintainability.
- Very specific: line 175
Run ./tools/lint to catch style issues before committing, including mypy issues.
- Distinctive: line 177
Avoid lodash in favor of modern ECMAScript primitives where available, keeping in mind our browserlist.
- Distinctive: line 179
Prefer writing code that is readable without explanation over heavily commented code using clever tricks.
- Very specific: line 182
Use em units instead of px for computed CSS values that need to scale with font size.
- Distinctive: line 186
Review CSS for redundant rules: After writing CSS, review the full set of rules affecting the same elements.
- Distinctive: line 191
Check CSS change scope: When modifying CSS, always check what other pages or components use the same selectors, files, and classes.
- Distinctive: line 218
Create a commit that "fixes" a mistake from an earlier commit in the same PR.
- Distinctive: line 220
Add content in one commit only to remove or move it in the next.
- Distinctive: line 223
Leave commits that break if a later commit in the PR is dropped.
- Distinctive: line 224
When a commit is flagged as potentially droppable, verify all earlier commits work correctly without it.
- Distinctive: line 247
Before the colon is a lower-case brief gesture at subsystem (ex: "nginx" config) or feature (ex: "compose" for the compose box) being …
- Distinctive: line 249
Use a period at the end of the summary
- Very specific: line 260
Never: Partially fixes #123.
- Distinctive: line 267
Updating the HEAD commit: If the commit you need to modify is already at HEAD, just use git commit --amend directly.
- Very specific: line 271
Squashing fixups into existing commits: Create fixup commits with git commit --fixup=<target-hash>, then write a shell script that outputs …
- Distinctive: line 283
Rewording commit messages: Use git format-patch to export commits as patch files, edit the message headers in the patch files, then reapply:
- Distinctive: line 316
Write end-to-end tests when possible verifying what's important, not internal APIs.
- Distinctive: line 320
Use time_machine and similar libraries to mock time.
- Very specific: line 321
Read zerver/tests/test_example.py for patterns.
- Distinctive: line 334
If a PR makes frontend changes, manually verify the affected UI.
- Distinctive: line 346
Do clickable elements have hover behavior consistent with similar UI?
- Distinctive: line 347
If elements can be disabled, does the disabled state look right?
- Distinctive: line 352
Check all of the above in both light and dark themes when the change could plausibly affect colors, contrast, or theme-dependent imagery.
- Distinctive: line 371
If the feature affects the message view, try different narrows: topic, channel, Combined feed, direct messages.
- Distinctive: line 373
If the feature affects the compose box, test both channel messages and direct messages, and both ways of resizing.
- Distinctive: line 375
If the feature requires elevated permissions, test as both a user who has permissions and one who does not.
- Distinctive: line 384
When using Puppeteer to verify visual alignment, do not rely on eyeballing screenshots — especially small full-page ones.
- Very specific: line 387
Use page.evaluate() with getBoundingClientRect() to measure actual pixel positions of the elements you need aligned, and print them to the …
- Distinctive: line 390
Always take both a full-page screenshot and a zoomed clip of the area of interest.
- Distinctive: line 429
Always output a recommend pull request summary+description that follow's Zulip's guidelines once you finish preparing a series of commits.
- Distinctive: line 443
Mitigation: When you find any issue during verification, fix it before presenting the work.
- Distinctive: line 451
Mitigation: Always show existing similar code first before implementing.
- Distinctive: line 457
Mitigation: Ensure all functions have complete type annotations.
- Distinctive: line 474
Mitigation: Keep summary under 72 characters.
- Very specific: line 490
Don't use Any type annotations without comments justifying it.
- Very specific: line 491
Don't use cursor.execute() with string formatting (SQL injection risk)
- Very specific: line 492
Don't use .extra() in Django without careful review and commenting
- Very specific: line 493
Don't use onclick attributes in HTML.
- Very specific: line 494
Don't access DOM APIs (document.documentElement.style, $() selectors for specific elements) without guarding for node test environments, …
- Distinctive: line 498
Don't create N+1 query patterns:
- Distinctive: line 515
Always check if you're working on top of the latest upstream/main, and fetch + rebase when starting a project so you're not using a stale …
- Distinctive: line 517
If you're continuing a project, start by rebasing, resolving merge conflicts carefully.
- Distinctive: line 519
Don't make design or UX decisions silently.
- Distinctive: line 523
Don't submit code you haven't tested
- Distinctive: line 524
Don't skip becoming familiar with the code you're modifying
- Distinctive: line 525
Don't make claims about code behavior without verification, and cite your sources.
- Distinctive: line 527
Don't generate PR descriptions that just describe what files changed
- Distinctive: line 528
Always do a pre-mortem: Think about how to avoid a bug recurring, how it might break something that already works, or imagine under what …
- Very specific: line 536
When opening a pull request, prefix the PR title with [ai] (e.g., [ai] compose: Fix cursor position after emoji insertion.).
- Very specific: line 543
Start with a Fixes: #... line linking the issue being addressed.
- Distinctive: line 549
Call out any open questions, concerns, or decisions you are uncertain about, so they can be resolved during review.
- Distinctive: line 581
Write tests that would have caught this bug if possible
- Distinctive: line 588
Read the relevant documentation in docs/
- Distinctive: line 600
No behavior changes unless explicitly discussed
- Distinctive: line 601
Verify completeness: use git grep to find all occurrences and confirm nothing was missed
- Distinctive: line 604
When removing a CSS dependency (e.g., Bootstrap), audit the full property list of every rule, not just visually obvious properties like …
- Very specific: line 615
Commit discipline: https://zulip.readthedocs.io/en/latest/contributing/commit-discipline.html
- Very specific: line 642
When making any user-facing change, read docs/documentation/helpcenter.md in full and review the relevant help center articles under …
- Very specific: line 650
When you encounter a Zulip narrow URL (e.g., from chat.zulip.org in a GitHub issue, PR, or user message), use the /fetch-zulip-messages …
- Very specific: line 667
If a tool complains that provision is outdated, run ./tools/provision to fix it.
≈ “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 - Guidelines for AI Contributions to Zulip
This file provides guidance to Claude (and other AI coding assistants) for contributing to the Zulip codebase. These guidelines are designed to produce contributions that meet the same high standards we expect from human contributors.
Philosophy
Zulip is a team chat application used by thousands of organizations, built to last for many years. It is developed by a vibrant open-source community, with maintainers who have consistently emphasized high standards for codebase readability, code review, commit discipline, debuggability, automated testing, tooling, documentation, and all the other subtle details that together determine whether software is easy to understand, operate, and modify.
Zulip's engineering strategy is to "move quickly without breaking things". This is possible because the project has invested years in testing, tooling, code structure, documentation, and development practices that catch bugs systematically rather than relying on individual vigilance. Maintainers spend most of their review time on product decisions and code structure/readability, not on chasing correctness issues — because the process is designed to prevent them.
This means Zulip's coding philosophy is to focus relentlessly on making the codebase easy to understand and difficult to make dangerous mistakes. This applies equally to AI-generated contributions. Every change should make the codebase more maintainable and easier to read.
No detail is too small
Zulip holds itself to a high bar for polish because users depend on this software daily, and because the project is built to last for decades. There is no category of "minor issue" that is acceptable to ship — if something is broken in any context where a user would encounter it, it must be fixed before merging. The project's extensive investment in testing, tooling, and review processes exists precisely so that these issues get caught and fixed, not so that they can be classified as low-priority and deferred.
This philosophy extends to every aspect of the product:
- Visual precision matters. Alignment, spacing, colors, and font sizes must be consistent with similar existing UI. When making CSS changes, you must demonstrate with pixel-precise before/after comparisons that there are no unintended side effects.
- Every state matters. UI must look correct in all its states:
hover, active, disabled, focused, selected, empty, overflowing.
Changes that could plausibly affect colors, contrast, or
theme-dependent imagery must work in both light and dark themes;
changes whose effect can't reasonably vary with theme (pure
geometry/typography —
font-size,line-height,margin,padding,display,font-weight, etc.) only need a single theme verified. - Every window size matters. UI must look good from wide desktop (1920px) down to narrow phone screens (480px).
- Every language matters. Translated strings can be 1.5x longer than English or half as short. UI must handle both extremes without breaking layout. Think about right-to-left languages too.
- Every interaction path matters. Keyboard navigation, screen readers, permission levels, feature interactions (banners overlapping, resolved topics, muted messages), and edge cases in data (empty lists, very long names, single items vs. many) must all be considered.
The right attitude is: "What could go wrong, and how do I verify that it doesn't?" not "It looks fine to me." What isn't tested probably doesn't work — this applies to visual changes just as much as to backend logic.
Understand before coding
Before writing any code, you must understand:
- What the existing code does and why, including the relevant help center or developer-facing documentation.
- What problem you're solving, in its full scope.
- Why your approach is the right solution, and available alternatives.
- How you will verify that your work is correct, and avoid regressions that are plausible for the type of work you're doing.
The answer to "Why is X an improvement?" should never be "I'm not sure."
Workflow
Follow this workflow for every task: understand → propose → implement → verify.
1. Understand Before Coding
Before making any changes:
# Read relevant documentation
cat docs/*/<relevant-area>.md
cat starlight_help/src/content/docs/<topic>.md
cat api_docs/<topic>.md and read the relevant part of zerver/openapi/zulip.yaml
# Look at existing code patterns
git grep "similar_function_name"
git log --oneline -20 -- path/to/file.py
# Check for related issues on GitHubAlways show existing similar code and explain how it works before proposing changes.
2. Propose an Approach
Before writing code, explain the plan:
- Explain your understanding of the problem and all relevant design decisions
- What changes are needed and why
- How the changes fit with existing patterns
- What could break and how to prevent regressions
3. Implement in Minimal, Coherent Commits
Structure changes as clean commits:
- Backend and API changes (with tests and API doc changes documented
fully using our double-entry changelog system). When starting an API
change, reread
docs/documentation/api.mdto review the process for documenting an API change. Runtools/create-api-changelog; it generates an emptyapi_docs/unmerged.d/ZF-XXXXXX.mdfile (whereXXXXXXis a random hex string the tool picks for you) and stages it for you. Document the changes in that file with the header**Feature level ZF-XXXXXX**and an unordered list (*bullets) of the additions or changes, formatted to matchapi_docs/changelog.md. In the OpenAPI yaml (zerver/openapi/zulip.yaml), reference the same filename stem in Changes notes, e.g.,**Changes**: New in Zulip 12.0 (feature level ZF-XXXXXX).The merge process replaces the placeholder with the final feature level. Never updateAPI_FEATURE_LEVELmanually. - Frontend UI changes (with tests and user-facing documentation updates). Remember to plan to use your visual test skill to check your work whenever you change web app code (HTML, CSS, JS).
Each commit should be self-contained, highly readable and reviewable
using git show --color-moved, and pass lint/tests independently. If
extracting new files or moving code, always do that in a separate
commit from other changes.
4. Verify Before Finalizing
Run tests before making a commit. Always manage your time by running specific test collections, not the entire test suite:
# Includes mypy and typescript checkers
./tools/lint path/to/changed/files.py
./tools/test-backend zerver.tests.test_relevant_moduleBefore You Start
Read the Relevant Documentation
Zulip has over 185,000 words of developer documentation. Before working on any area:
- Read documentation from docs/, starlight_help/src/content/docs/, and api_docs/.
- Read existing code in the area you're modifying.
- Use
git grepto find similar patterns in the codebase and read those.
Understand the Code Style
- Be consistent with existing code. Look at surrounding code and follow the same patterns, as this is a thoughtfully crafted codebase.
- Use clear, greppable names for functions, arguments, variables, and
tests. Future developers will
git grepfor relevant terms when researching a problem, so names should communicate purpose clearly. - Keep everything well factored for maintainability. Avoid duplicating code, especially where access control or subtle correctness is involved.
- Run
./tools/lintto catch style issues before committing, including mypy issues. - JavaScript/TypeScript code must use
constorlet, nevervar. - Avoid lodash in favor of modern ECMAScript primitives where available, keeping in mind our browserlist.
- Prefer writing code that is readable without explanation over heavily commented code using clever tricks. Comments should explain "why" when the reason isn't obvious, not narrate "what" the code does.
- Use
emunits instead ofpxfor computed CSS values that need to scale with font size. Pixel approximations break at different zoom levels and font-size settings. - Comments should have a line to themself except for CSS px math.
- Review CSS for redundant rules. After writing CSS, review the
full set of rules affecting the same elements. Look for rules that
are immediately overridden by a more specific selector, duplicated
selector lists, or cases where scoping (e.g.,
:not()) would eliminate the need for an override. - Check CSS change scope. When modifying CSS, always check what
other pages or components use the same selectors, files, and
classes. Use
git grepon class names and check webpack bundle entries to understand which pages load the file. Prefer scoped overrides (e.g.,.parent .target) over modifying shared rules, to avoid unintended changes to other parts of the app.
See: https://zulip.readthedocs.io/en/latest/contributing/code-style.html
Commit Discipline
Zulip follows the Git project's practice of "Each commit is a minimal coherent idea." This is non-negotiable.
Each Commit Must:
- Be coherent: Implement one logical change completely and atomically.
- Pass tests: Include test updates in the same commit as code changes.
- Not make Zulip worse: Work is ordered so no commit has regressions.
- Be safe to deploy individually: Or explain in detail why not.
- Be minimal and reviewable: Don't combine moving code with changing it in the same commit; make liberal use of small prep commits for no-op refactoring that are easy to verify.
Never:
- Mix multiple separable changes in a single commit.
- Create a commit that "fixes" a mistake from an earlier commit in the same PR; always edit Git to fix the original commit.
- Add content in one commit only to remove or move it in the next; plan upfront what belongs where and do it right the first time.
- Include debugging code, commented-out code, or temporary TODOs.
- Leave commits that break if a later commit in the PR is dropped. When a commit is flagged as potentially droppable, verify all earlier commits work correctly without it.
Commit Message Format
subsystem: Summary in 72 characters or less.
The body explains why and how. Include context that helps reviewers
and future developers understand your reasoning, analysis, and
verification of the work above and beyond CI, without repeating
details already well presented in the commit metadata (filenames,
etc.). Explain what the change accomplishes and why it won't break
things one might worry about.
Line-wrap at 68-70 characters, except URLs and verbatim content
(error messages, etc.).
Fixes #123.Commit summary format:
- Before the colon is a lower-case brief gesture at subsystem (ex: "nginx" config) or feature (ex: "compose" for the compose box) being modified.
- Use a period at the end of the summary
- Example:
compose: Fix cursor position after emoji insertion. - Example:
nginx: Refactor immutable cache headers. - Bad examples:
Fix bug,Update code,gather_subscriptions was broken
Linking issues:
Fixes #123.- Automatically closes the issueFixes part of #123.- Does not close (for partial fixes)- In a multi-commit PR, use
Fixes part of #123.in earlier commits andFixes #123.in the final commit. - Never:
Partially fixes #123.(GitHub ignores "partially")
Rebasing Commits (Non-Interactive)
Since git rebase -i requires an interactive editor, use
GIT_SEQUENCE_EDITOR to supply the todo list via a script:
- Updating the HEAD commit: If the commit you need to modify is
already at HEAD, just use
git commit --amenddirectly. The fixup+rebase workflow below is only needed for non-HEAD commits. Squashing fixups into existing commits: Create fixup commits with
git commit --fixup=<target-hash>, then write a shell script that outputs the desired todo (withpickandfixuplines in order) and run:GIT_SEQUENCE_EDITOR=/path/to/todo-script.sh git rebase -i <base>Note:
--autosquashalone without-idoes not reorder or squash anything.Rewording commit messages: Use
git format-patchto export commits as patch files, edit the message headers in the patch files, then reapply:git format-patch <base> -o /tmp/patches/ # Edit the commit message in each /tmp/patches/000N-*.patch file # (the message is between the Subject: line and the --- line) git reset --hard <base> git am /tmp/patches/*.patch
Testing Requirements
Zulip server takes pride in its ~98% test coverage. All server changes must include nice tests that follow our testing philosophy.
Before Submitting:
./tools/test-js-with-node # JavaScript tests; full suite fast enough
./tools/lint # Run all linters
./tools/test-backend # Python testsA common failure mode is failing to have test coverage for error
conditions that require coverage (note tools/coveragerc excludes
asserts). Run test-backend --coverage FooTest and check the coverage
data to confirm that the new lines you added are in fact run by the
tests.
Testing Philosophy:
- Write end-to-end tests when possible verifying what's important, not internal APIs.
- Tests must work offline. Use fixtures (in
zerver/tests/fixtures) for external service testing andresponsesfor simpler things. - Use time_machine and similar libraries to mock time.
- Read
zerver/tests/test_example.pyfor patterns. - A good failing test before implementing is good practice so your test and code can jointly verify each other.
- Remember to always assert state is correctly updated, not just "success".
For Webhooks:
./tools/test-backend zerver/webhooks/<integration>Manual Testing for UI Changes
If a PR makes frontend changes, manually verify the affected UI. This catches issues that automated tests miss. Treat this checklist as blocking, not advisory — every applicable item must be verified before the change is ready.
Visual appearance:
- Is the new UI consistent with similar elements (fonts, colors, sizes)? Find the closest existing analogues and compare carefully.
- Is alignment correct, both vertically and horizontally? Measure
programmatically with
getBoundingClientRect()when in doubt — don't eyeball it. - Do clickable elements have hover behavior consistent with similar UI?
- If elements can be disabled, does the disabled state look right?
- Did the change accidentally affect other parts of the UI? Use
git grepto check if modified CSS is used elsewhere. CSS changes are notorious for unintended consequences — check every page and component that shares the selectors you modified. - Check all of the above in both light and dark themes when the
change could plausibly affect colors, contrast, or theme-dependent
imagery. Pure geometry/typography changes (
font-size,line-height,margin,padding,display,font-weight, etc.) don't need a separate dark-theme pass —web/styles/dark_theme.cssonly overrides colors, so a single theme suffices for theme-invariant changes.
Responsiveness and internationalization:
- Does the UI look good at different window sizes? Check wide desktop (1920px), typical laptop (1280px), tablet, and narrow phone (480px).
- Would the UI break if translated strings were 1.5x longer than English? What if they were half as long? Both directions matter.
Functionality:
- Are live updates working as expected?
- Is keyboard navigation, including tabbing to interactive elements, working?
- If the feature affects the message view, try different narrows: topic, channel, Combined feed, direct messages.
- If the feature affects the compose box, test both channel messages and direct messages, and both ways of resizing.
- If the feature requires elevated permissions, test as both a user who has permissions and one who does not.
- Think about feature interactions: could banners overlap? What about resolved/unresolved topics? Collapsed or muted messages?
- Think about edge cases in data: empty lists, very long names, single items vs. hundreds, special characters in strings.
Puppeteer Visual Tests: Verifying Alignment
When using Puppeteer to verify visual alignment, do not rely on eyeballing screenshots — especially small full-page ones. Instead:
- Use
page.evaluate()withgetBoundingClientRect()to measure actual pixel positions of the elements you need aligned, and print them to the console. Compare the numbers. - Always take both a full-page screenshot and a zoomed clip of the area of interest.
- For zoomed clips, calculate the clip region from non-fixed elements; fixed/sticky elements may report bounding-box positions that don't match their visual location on the page.
- Be aware that CSS nesting can scope styles to a specific parent
(e.g.,
.parent .my-class) — reusing the same class name in a different context may not pick up the expected styles. - To verify keyboard-focus styles, use real keyboard navigation
(
page.keyboard.press); programmatic.focus()doesn't reliably trigger:focus-visibleand may be overridden by view-level focus management. - Focus rings drawn as
::before/::afterpseudo-elements aren't visible ingetComputedStyleof the focused element — verify them in a screenshot, not via computed styles. - For visual changes, produce before/after screenshot pairs by writing
one test and running it twice with a
SCREENSHOT_SUFFIXenv var (-oldonmain,-updatedon your branch).
Self-Review Checklist
Before finalizing, verify:
- The PR addresses all points described in the issue
- All relevant tests pass locally
- Code follows existing patterns in the codebase
- Names (functions, variables, tests) are clear and greppable
- Commit messages, comments, and PR description are well done.
- Each commit is a minimal coherent idea
- No debugging code or unnecessary comments remain
- Type annotations are complete and correct
- User-facing strings are tagged for translation
- User-facing error messages are clear and actionable
- No secrets or credentials are hardcoded
- Documentation is updated if behavior changes
- Refactoring is complete (
git grepfor remaining occurrences) - Security audit of changes. Always check for XSS in UI changes and for incorrect access control in server changes.
Always output a recommend pull request summary+description that follow's Zulip's guidelines once you finish preparing a series of commits.
Common Pitfalls
Treating Known Issues as Acceptable
A common failure mode is discovering a problem during verification and then noting it as a known limitation rather than fixing it. At Zulip, there is no category of "known minor issue" that is acceptable to ship. If it's broken in any state, size, theme, or language, it needs to be fixed.
Mitigation: When you find any issue during verification, fix it before presenting the work. If a fix would require a design decision, raise it as a question rather than shipping the broken state.
Overconfident Code Generation
You may generate code that looks correct but doesn't match Zulip patterns.
Mitigation: Always show existing similar code first before implementing.
Incomplete Type Annotations
Python code must be fully typed for mypy.
Mitigation: Ensure all functions have complete type annotations. Run mypy (perhaps via the linter) to verify.
Missing Test Updates
Tests must be in the same commit as the code they test.
Mitigation: Include test updates in each commit. Show what tests need to change.
Verbose Commit Messages
Zulip commits are concise -- say everything that's important for a reviewer to understand about the motivation for the work and changes, and nothing more. Avoid wordiness and details obvious to someone who is looking at the commit and its metadata (lists of filenames, etc).
Mitigation: Keep summary under 72 characters. Body should explain why, not what.
Mixing Concerns
Multiple changes in one commit makes review difficult.
Mitigation: Each commit should do exactly one thing. Plan necessary refactoring and preparatory commits in advance of functional changes. You can split into good commits after the fact, but it's much faster and easier to just plan and write them well the first time.
What Not To Do
Code Quality:
- Don't use
Anytype annotations without comments justifying it. - Don't use
cursor.execute()with string formatting (SQL injection risk) - Don't use
.extra()in Django without careful review and commenting - Don't use
onclickattributes in HTML; use event delegation - Don't access DOM APIs (
document.documentElement.style,$()selectors for specific elements) without guarding for node test environments, where the DOM is mocked minimally. Check that the element exists before using it. Don't create N+1 query patterns:
# BAD for bar in bars: foo = Foo.objects.get(id=bar.foo_id) # GOOD foos = {f.id: f for f in Foo.objects.filter(id__in=[b.foo_id for b in bars])}- In tests, don't assert on
assertLogsoutput withany(phrase in line for line in mock_log.output); pin the full line againstmock_log.output, or a substring to a specificmock_log.output[i].
Process:
- Always check if you're working on top of the latest upstream/main, and fetch + rebase when starting a project so you're not using a stale branch. If you're continuing a project, start by rebasing, resolving merge conflicts carefully.
- Don't make design or UX decisions silently. When a technical constraint forces a tradeoff, present the constraint and options to the user rather than picking one. Never remove features, hide UI elements, or change interaction patterns without asking.
- Don't submit code you haven't tested
- Don't skip becoming familiar with the code you're modifying
- Don't make claims about code behavior without verification, and cite your sources.
- Don't generate PR descriptions that just describe what files changed
- Always do a pre-mortem: Think about how to avoid a bug recurring, how it might break something that already works, or imagine under what circumstances your changes might need to be reverted.
Pull Request Guidelines
PR Description Should:
When opening a pull request, prefix the PR title with [ai] (e.g.,
[ai] compose: Fix cursor position after emoji insertion.). Use
upstream/main as the base branch.
Output the PR description in a markdown code block so that formatting (bold, headers, checkboxes, etc.) copy-pastes correctly into GitHub.
- Start with a
Fixes: #...line linking the issue being addressed. - Explain why the change is needed, not just what changed.
- Describe how you tested the change, using checkbox format for the
test plan (e.g.,
- [x] ./tools/test-backend ...). - Include screenshots for UI changes.
- Link to relevant issues or discussions.
- Call out any open questions, concerns, or decisions you are uncertain about, so they can be resolved during review.
- Include the self-review checklist from
.github/pull_request_template.mdusing checkbox format (- [x]/- [ ]), checking off all applicable items.
PR Description Should Not:
- Regurgitate information visible from the diff
- Make claims you haven't double-checked
- Express more certainty than is justified given the evidence
When to Pause and Discuss
Recommend pausing for discussion when:
- The approach involves security-sensitive code
- Database migrations are needed (See
docs/subsystems/schema-migrations.md). - The change affects many files (>10)
- Performance implications are unclear
- The feature design isn't fully specified
- The API or data model design isn't fully specified
- An API change may not be compatible (See
docs/processes/api-design.md). - Existing tests are failing for unclear reasons
Task-Specific Approaches
For Bug Fixes
- Show the relevant code and explain what's happening
- Brainstorm theories for how the bug might be possible
- Analyze and propose a fix with a clear explanation
- Write tests that would have caught this bug if possible
- Format as a single commit following commit guidelines
- Audit for whether the bug may exist elsewhere or might be re-introduced and propose appropriate changes to address if so.
For New Features
- Read the relevant documentation in docs/
- Show similar existing features in the codebase
- Propose an implementation approach before coding
- Implement in minimal, coherent commits
- Each commit must pass tests independently
For Refactoring
- Show the current implementation
- Explain what makes it problematic
- Propose the refactoring approach
- Implement in commits that each leave the codebase working
- No behavior changes unless explicitly discussed
- Verify completeness: use
git grepto find all occurrences and confirm nothing was missed
When removing a CSS dependency (e.g., Bootstrap), audit the full
property list of every rule, not just visually obvious properties like
colors and backgrounds. Subtle properties like line-height, margin,
padding, text-decoration, font-weight, and border are easy to
miss but cause visible regressions. Check inherited properties too —
e.g., a body rule's line-height or margin affects all descendants.
Key Documentation Links
- Contributing guide: https://zulip.readthedocs.io/en/latest/contributing/contributing.html
- Code style: https://zulip.readthedocs.io/en/latest/contributing/code-style.html
- Commit discipline: https://zulip.readthedocs.io/en/latest/contributing/commit-discipline.html
- Testing overview: https://zulip.readthedocs.io/en/latest/testing/testing.html
- Backend tests: https://zulip.readthedocs.io/en/latest/testing/testing-with-django.html
- Code review: https://zulip.readthedocs.io/en/latest/contributing/code-reviewing.html
- mypy guide: https://zulip.readthedocs.io/en/latest/testing/mypy.html
Repository Structure Quick Reference
zerver/ # Main Django app
models/ # Database models
views/ # API endpoints
lib/ # Shared utilities
tests/ # Backend tests
webhooks/ # Integration webhooks
web/ # Frontend TypeScript/JavaScript
src/ # Main frontend code
styles/ # CSS
templates/ # Frontend HTML
tests/ # Frontend tests
templates/ # Jinja2/Handlebars templates
tools/ # Development and testing scripts
docs/ # ReadTheDocs documentation sourceHelp Center Documentation
When making any user-facing change, read
docs/documentation/helpcenter.md in full and review the relevant
help center articles under starlight_help/src/content/docs/ for any
updates that should be made. The writing guide there is the source
of truth for help center conventions, components, and structure.
Zulip Chat Links
When you encounter a Zulip narrow URL (e.g., from chat.zulip.org in a
GitHub issue, PR, or user message), use the /fetch-zulip-messages skill
to read the conversation. Do not use WebFetch — it cannot access Zulip
message content.
Common Commands
./tools/provision # Set up development environment
./tools/run-dev # Start development server
./tools/lint # Run all linters
./tools/test-backend # Run Python tests
./tools/test-js-with-node # Run JavaScript tests
./tools/run-mypy # Run type checker
git grep "pattern" # Search codebase (use extensively!)If a tool complains that provision is outdated, run ./tools/provision
to fix it. Do not use --skip-provision-check to work around the
error; the check exists because tests and linters depend on provisioned
dependencies being current.
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.

