Skip to content

docs: compact CLAUDE.md/AGENTS.md to load-bearing rules - #5606

Closed
lawrencecchen wants to merge 2 commits into
mainfrom
feat-compact-agent-guide
Closed

lawrencecchen wants to merge 2 commits into
mainfrom
feat-compact-agent-guide

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Compacts CLAUDE.md (the file AGENTS.md symlinks to) from 533 → 313 lines by moving reference material into self-contained in-repo docs and deduplicating repeated prose. No load-bearing rule is dropped.

The symlink AGENTS.md -> CLAUDE.md is unchanged.

Why

CLAUDE.md/AGENTS.md is pasted into every agent's context window on every task. It should carry constraints an agent would otherwise get wrong, not reference essays that apply to a minority of tasks. Today ~180 of the 533 lines are the Swift package/architecture guidance, which only matters when a task extracts a Packages/ module and is already enforced by the review bots (Codex, CodeRabbit, Greptile). For the other ~95% of tasks (bug fixes, UI tweaks, CLI work) it is dead weight crowding out the rules that do apply.

What moved (content preserved verbatim in docs/, summarized in-file)

  • The Swift sections (Package architecture, Refactor architecture / Coordinator-Service-Repository / dependency inversion, File organization, Documentation/DocC, Package design discipline, Testability, Modern Swift concurrency, Test framework) → docs/swift-architecture.md (~164 lines, verbatim). CLAUDE.md keeps a load-bearing summary + pointer. This also fixes a real gap: the old in-file pointer to hq's docs/cmux-refactor-audit/blueprint/ is unfollowable for an external contributor; the new doc is the canonical in-repo copy.
  • The sidebar extension-point how-to → docs/sidebar-extension-point.md.

What was compressed in place (every command/fact kept)

  • Xcode toolchain: 3 paragraphs → 1, same pin / objectVersion = 60 / CI-enforcement facts.
  • Local dev: the reload.sh behavior was explained four separate times; merged into one. Kept every script (reload/reloadp/reloads/reload2), the compile-only xcodebuild invocation, the cmux-debug-cli helper, and the file:// link block verbatim (deliberately not redirected to hq's Tag Opener, which external manaflow-ai/cmux contributors do not have).
  • Debug event log: kept the implementation + #if DEBUG contract; replaced the exhaustive event-name catalog with a grep cmuxDebugLog pointer (the catalog is regenerable from code, not a rule).

Conservation

Every original ## section is either kept in-file or moved to a pointed-to in-repo doc:

Original section New location
Initial setup, Cloud VM secrets, Backend TypeScript, Regression test policy, Shared behavior, Debug menu, Pitfalls, Test quality policy, Socket threading/focus, Testing policy, Ghostty, Release kept in CLAUDE.md
Xcode toolchain, Local dev, Debug event log kept, compressed in place
Package/Refactor architecture, File organization, Documentation, Package design discipline, Testability, Modern Swift concurrency, Test framework docs/swift-architecture.md (summary + pointer in-file)
Sidebar extension point docs/sidebar-extension-point.md (pointer in-file)

Two commits so the move is reviewable: commit 1 adds the docs (verbatim relocation), commit 2 trims CLAUDE.md.

Meta-only change; no runtime/app behavior touched.

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Low Risk
Documentation-only reorganization; no application code, build scripts, or runtime behavior changes.

Overview
Shrinks CLAUDE.md (and the AGENTS.md symlink) so agent context stays lean: long Swift/package guidance and sidebar extension mechanics move into docs/swift-architecture.md and docs/sidebar-extension-point.md, while CLAUDE.md keeps a short load-bearing summary plus links.

In-file sections are tightened without dropping commands or constraints—Xcode toolchain, local dev (reload.sh, tagged builds, file:// app links, cmux-debug-cli), and debug event log (catalog replaced with a grep cmuxDebugLog pointer). The former multi-section Swift architecture, concurrency, testability, and test-framework essays are consolidated behind docs/swift-architecture.md so external contributors get an in-repo canonical copy instead of an unfollowable hq blueprint link.

Reviewed by Cursor Bugbot for commit a375e5d. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Compacted CLAUDE.md/AGENTS.md by moving long-form Swift architecture and sidebar extension docs into repo docs while keeping all load‑bearing rules; file size drops 533 → 313 lines. No runtime changes.

  • Refactors
    • Moved Swift architecture, file-organization, DocC, testability, concurrency, and test framework content to docs/swift-architecture.md (CLAUDE.md now has a short summary + pointer).
    • Moved the sidebar ExtensionKit how-to to docs/sidebar-extension-point.md.
    • Compressed in place: Xcode toolchain pinning, local dev (reload.sh and helpers), and debug event log (kept implementation + grep pointer). Symlink AGENTS.md -> CLAUDE.md remains unchanged.

Written for commit a375e5d. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Documentation
    • Updated internal development architecture guidance and build configuration documentation for reference.

Note: This release contains documentation-only updates with no visible changes to end-user functionality or features.

lawrencecchen and others added 2 commits June 7, 2026 20:37
…E.md

Move the verbatim Swift package/architecture conventions and the sidebar
extension-point how-to into self-contained in-repo docs. CLAUDE.md will
point to these and keep only the load-bearing summary, so the per-task
agent context stops carrying ~180 lines that apply only to Packages/ work
and are already enforced by the review bots.

No content changed; this commit only relocates it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
533 -> 313 lines. CLAUDE.md (== AGENTS.md) is loaded into every agent's
context on every task, so it should hold constraints agents would get
wrong, not reference essays that apply to a minority of tasks.

What moved (content preserved verbatim in docs/, summarized in-file):
- Swift package/architecture, file-org, DocC, package-design, testability,
  modern-concurrency, and test-framework sections -> docs/swift-architecture.md
  (~160 lines). Replaced by a load-bearing summary + pointer.
- Sidebar extension-point how-to -> docs/sidebar-extension-point.md.

What was compressed in place (every command/fact kept):
- Xcode toolchain: 3 paragraphs -> 1, same pin/objectVersion/CI facts.
- Local dev: deduped the reload.sh explanation (repeated 4x) into one;
  kept every script (reload/reloadp/reloads/reload2), the compile-only
  xcodebuild, the cmux-debug-cli helper, and the file:// link block
  verbatim (correct for external contributors, who have no Tag Opener).
- Debug event log: kept the impl/#if-DEBUG contract; replaced the
  exhaustive event-name catalog with a grep pointer.

Nothing load-bearing dropped; the review bots still enforce the Swift rules.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jun 8, 2026 4:09am
cmux-staging Building Building Preview, Comment Jun 8, 2026 4:09am

@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR consolidates and expands development guidance across CLAUDE.md and two new documentation files. Local build and debug instrumentation guidance in CLAUDE.md is refined, a new spec documents ExtensionKit sidebar extension point isolation for tagged builds, and a comprehensive Swift architecture conventions document is introduced. CLAUDE.md's architecture policies are condensed to reference external specs instead.

Changes

Development Documentation Consolidation

Layer / File(s) Summary
Local dev build and toolchain guidance
CLAUDE.md
Xcode toolchain pinning and tagged-only build practices are refined; new structured guidance covers reload.sh usage, tagged xcodebuild patterns, and build/reload script organization with tag isolation details.
Debug instrumentation guidance
CLAUDE.md
Debug event log section is reworked to reference event catalogs by key prefix (focus.*, tab.*, pane.*, divider.*) instead of enumerating prior specific event keys.
Extension point isolation for tagged builds
docs/sidebar-extension-point.md
New documentation file specifies how ExtensionKit sidebar extension points are isolated in tagged dev builds, including build settings, host runtime resolution, reload script conventions, signing constraints, and authoring steps for new tag-ready sample extensions.
Swift architecture and package conventions
CLAUDE.md, docs/swift-architecture.md
New comprehensive architecture spec defines Swift package dependency DAG rules, layered architecture, strict DI/inversion requirements, concurrency constraints, file organization, documentation standards, and test framework guidance. CLAUDE.md's large architecture-policy section is consolidated into a shorter reference pointing to external specs; test framework section is removed.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly Related PRs

  • manaflow-ai/cmux#5111: Both PRs modify CLAUDE.md documentation in overlapping areas—especially the repo's refactor/package architecture rules and the reload.sh/build-vs-tests behavior guidance—so the changes are directly related.

Poem

🐰 A rabbit's thoughts on clearer paths:
Build rules refined, tagged dev baths,
Architecture laid out neat,
Extension points and doc retreat,
Guidance consolidated—sweet!


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (2 errors, 1 inconclusive)

Check name Status Explanation Resolution
Cmux Swift Blocking Runtime ❌ Error Production Swift code in CLI/CMUXCLI+Process.swift introduces blocking synchronization: DispatchSemaphore.wait(), NSLock, and @unchecked Sendable without safety explanation. Replace DispatchSemaphore/NSLock with async/await, actors, or explicit signals; document @unchecked Sendable safety or use actor isolation.
Cmux Source Artifacts ❌ Error .claude/scheduled_tasks.lock contains local tool runtime state (PIDs, session IDs, timestamps) and violates the policy prohibiting "local tool output" without deliberate product/documentation reason. Remove .claude/scheduled_tasks.lock from commit or add .claude/*.lock pattern to .gitignore to prevent runtime state files from being checked in.
Description check ❓ Inconclusive The description comprehensively covers the 'What' (moved 533→313 lines, preserved all load-bearing rules) and 'Why' (keep agent context lean for general tasks), but does not follow the provided template structure with 'Summary', 'Testing', 'Demo Video', 'Review Trigger', and 'Checklist' sections. Restructure the description to follow the repository template: add 'Testing' section documenting how you verified the links and formatting are correct, include the 'Review Trigger' bot comment block, and check off the 'Checklist' items (particularly testing, docs updates, and bot review requests).
✅ Passed checks (16 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: compact CLAUDE.md/AGENTS.md to load-bearing rules' directly and clearly describes the main change: compacting documentation files while preserving essential constraints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Swift Actor Isolation ✅ Passed Documentation-only PR (CLAUDE.md, swift-architecture.md, sidebar-extension-point.md) with zero modified Swift production files; no code changes means no actor isolation issues.
Cmux No Hacky Sleeps ✅ Passed PR contains only documentation changes (CLAUDE.md, sidebar-extension-point.md, swift-architecture.md) with no production code changes violating the no-hacky-sleeps rule.
Cmux Algorithmic Complexity ✅ Passed PR modifies only documentation files (CLAUDE.md, docs/swift-architecture.md, docs/sidebar-extension-point.md). Algorithmic complexity rule applies to production code, not documentation.
Cmux Swift Concurrency ✅ Passed No legacy async patterns in cmux code. DispatchQueue/Semaphore use only at OS API boundaries (Process piping, file watching). Observable patterns use modern @Observable + AsyncStream.
Cmux Swift @Concurrent ✅ Passed PR contains documentation-only changes (.md files); no Swift source code modifications, so @concurrent annotation check is not applicable.
Cmux Swift File And Package Boundaries ✅ Passed PR contains only documentation changes (.md files). No Swift files were modified, making the Swift file/package boundaries check inapplicable.
Cmux Swift Logging ✅ Passed PR contains only documentation changes (CLAUDE.md and new docs files). No Swift code or logging changes were introduced by the PR.
Cmux User-Facing Error Privacy ✅ Passed PR is documentation-only (CLAUDE.md and two new .md files); check explicitly allows docs content that aren't shown to end users.
Cmux Full Internationalization ✅ Passed PR adds documentation-only files (CLAUDE.md, sidebar-extension-point.md, swift-architecture.md) that are operational docs not shown to end users, exempt per review-bot-rules.
Cmux Swiftui State Layout ✅ Passed PR contains only documentation (.md) changes; no Swift code, SwiftUI state, or Observable/ObservableObject modifications present. Check is inapplicable.
Cmux Architecture Rethink ✅ Passed PR is documentation-only, adding docs/swift-architecture.md which correctly enforces Swift architectural rules. No Swift code violates sleeps/locks/observers prohibitions.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed All user-visible cmux windows have stable cmux.* identifiers registered in cmuxAuxiliaryWindowIdentifiers with proper close-shortcut routing; unregistered windows are internal/hidden.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-compact-agent-guide

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR compresses CLAUDE.md from 533 → 313 lines by relocating Swift package/architecture guidance and the sidebar extension-point how-to into dedicated docs/ files, retaining compact in-file summaries with pointers. No runtime or app behavior is changed.

  • docs/swift-architecture.md (164 lines) — verbatim relocation of Package architecture, Refactor architecture, File organization, Documentation, Package design discipline, Testability, Modern Swift concurrency, and Test framework sections; CLAUDE.md keeps a 7-bullet summary + pointer.
  • docs/sidebar-extension-point.md (18 lines) — verbatim relocation of the sidebar extension-point tagging how-to; CLAUDE.md keeps a pointer.
  • Xcode toolchain, Local dev, and Debug event log sections are compressed in-place (all commands and rules preserved; event-name catalog replaced with a grep cmuxDebugLog pointer).

Confidence Score: 5/5

Safe to merge — documentation reorganization only, no runtime or app behavior touched.

All three files are documentation. Content from CLAUDE.md is either preserved verbatim in the new docs/ files or kept in compressed form with accurate pointers. Every script command, build rule, and architecture constraint is reachable from CLAUDE.md. The review bots continue to enforce the full Swift rules via .github/review-bot-rules/ regardless of what is summarized in CLAUDE.md.

No files require special attention.

Important Files Changed

Filename Overview
CLAUDE.md Compressed from ~533 to ~313 lines; all commands and load-bearing rules preserved in-file or pointed to docs/; the reloadp/reloads/reload2 bash examples are consolidated into a bullet list (content intact), and the debug event-name catalog is replaced by a grep pointer.
docs/swift-architecture.md New file; verbatim relocation of Swift package/architecture, concurrency, testability, file-organization, documentation, and test-framework rules from CLAUDE.md. Content is identical to what was in CLAUDE.md; review bots enforce these rules on PRs via .github/review-bot-rules/.
docs/sidebar-extension-point.md New file; verbatim relocation of the sidebar extension-point tagging how-to (18 lines). No content changes; CLAUDE.md pointer is correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent / CLAUDE.md loaded on every task] --> B{Task type?}
    B -->|Swift/Package work| C[Read docs/swift-architecture.md\n164 lines — full rules]
    B -->|Sidebar extension tagging| D[Read docs/sidebar-extension-point.md\n18 lines — full mechanics]
    B -->|All other tasks ~95%| E[CLAUDE.md only\n313 lines — summaries + commands]
    C --> F[Review bots enforce via\n.github/review-bot-rules/]
    D --> F
    E --> G[No wasted context window]
Loading

Reviews (1): Last reviewed commit: "docs: trim CLAUDE.md to load-bearing rul..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CLAUDE.md`:
- Line 76: Update the GhosttyKit rebuild command to include the missing flag so
it reads the canonical form: add the -Demit-macos-app=false option to the
existing Zig build invocation (the command that currently contains "zig build
-Demit-xcframework=true -Dxcframework-target=universal -Doptimize=ReleaseFast")
to prevent unintentionally building/installing Ghostty.app as a side effect.

In `@docs/swift-architecture.md`:
- Line 161: The documentation line allowing "local runs" alongside CI filtering
conflicts with the repo policy; update the sentence that references test tagging
(e.g., `@Test`(.tags(.something)) and `@Suite`) to remove any mention of running
tests locally and explicitly state that tags are used for CI/VM-based selective
runs only (e.g., via GitHub Actions or the VM), ensuring the doc aligns with the
"Never run tests locally" guideline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 15d36e9a-a4cb-4030-b9c2-a663f6605093

📥 Commits

Reviewing files that changed from the base of the PR and between 1c20831 and a375e5d.

📒 Files selected for processing (3)
  • CLAUDE.md
  • docs/sidebar-extension-point.md
  • docs/swift-architecture.md

Comment thread CLAUDE.md
When rebuilding GhosttyKit.xcframework or cmuxd for release/bundling, always use Release optimizations:

```bash
cd ghostty && zig build -Demit-xcframework=true -Dxcframework-target=universal -Doptimize=ReleaseFast

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add -Demit-macos-app=false to the GhosttyKit rebuild command.

The documented command currently omits the required -Demit-macos-app=false flag, which can unintentionally build/install Ghostty.app as a side effect and add avoidable build time. Please update the command to the canonical form.

Suggested diff
-cd ghostty && zig build -Demit-xcframework=true -Dxcframework-target=universal -Doptimize=ReleaseFast
+cd ghostty && zig build -Demit-xcframework=true -Demit-macos-app=false -Dxcframework-target=universal -Doptimize=ReleaseFast

Based on learnings, the canonical GhosttyKit command requires -Demit-macos-app=false to prevent unintended app build side effects.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CLAUDE.md` at line 76, Update the GhosttyKit rebuild command to include the
missing flag so it reads the canonical form: add the -Demit-macos-app=false
option to the existing Zig build invocation (the command that currently contains
"zig build -Demit-xcframework=true -Dxcframework-target=universal
-Doptimize=ReleaseFast") to prevent unintentionally building/installing
Ghostty.app as a side effect.

Source: Learnings

- **Migration guide when touching an existing XCTest test.** Convert in place: `XCTestCase` subclass becomes a `@Suite struct` (or `final class` if you need a reference type); each `func testFoo()` becomes `@Test func foo()`; `XCTAssertEqual(a, b)` becomes `#expect(a == b)`; `XCTAssertTrue(cond)` becomes `#expect(cond)`; `XCTUnwrap(x)` becomes `try #require(x)`; `XCTFail("msg")` becomes `Issue.record("msg")`. `setUp()` becomes `init()` on the suite; `tearDown()` becomes `deinit`. Async setup is `async init()`. Do not bulk-rewrite untouched tests; migrate incrementally as a side effect of editing the file.
- **Parameterized tests** use `@Test(arguments: [...])`. Prefer this over duplicate test methods.
- **Parallelization and shared state.** Swift Testing runs tests in parallel by default, including across suites. If a suite genuinely needs ordering or guards shared mutable state, annotate it with `.serialized` instead of adding locks or sleeps.
- **Tags** with `@Test(.tags(.something))` (or on a `@Suite`) let CI and local runs filter selectively.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove the “local runs” guidance to avoid policy contradiction.

Line 161 conflicts with the repo policy that tests should not be run locally; keeping both instructions will cause operator confusion.

As per coding guidelines: “Never run tests locally. All tests (E2E, UI, python socket tests) run via GitHub Actions or on the VM.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/swift-architecture.md` at line 161, The documentation line allowing
"local runs" alongside CI filtering conflicts with the repo policy; update the
sentence that references test tagging (e.g., `@Test`(.tags(.something)) and
`@Suite`) to remove any mention of running tests locally and explicitly state that
tags are used for CI/VM-based selective runs only (e.g., via GitHub Actions or
the VM), ensuring the doc aligns with the "Never run tests locally" guideline.

Source: Coding guidelines

@lawrencecchen lawrencecchen added the stale-revisit Closed after 30+ days without activity; preserved for possible revisit or reopening. label Sep 23, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in cmux backlog Sep 23, 2026

This branch was successfully deployed

1 active deployment
Preview – cmux — a375e5d8 Deployed Jun 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale-revisit Closed after 30+ days without activity; preserved for possible revisit or reopening.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants