Skip to content

docs: restructure CLAUDE.md into governance core + modular playbooks#30

Merged
phuongnse merged 3 commits into
mainfrom
docs/improve-claude-md-governance
May 16, 2026
Merged

docs: restructure CLAUDE.md into governance core + modular playbooks#30
phuongnse merged 3 commits into
mainfrom
docs/improve-claude-md-governance

Conversation

@phuongnse

@phuongnse phuongnse commented May 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Restructure CLAUDE.md into a governance core — keeps only enforcement rules, severity model, and architectural boundaries; moves implementation detail to playbooks
  • Move docs/PROCESS.mddocs/playbooks/process.md and docs/PATTERNS.mddocs/playbooks/patterns.md
  • Add 3 new playbooks: testing.md, frontend.md, wireframes.md — each with bidirectional navigation links back to docs/README.md and CLAUDE.md

Key additions to CLAUDE.md

Addition Purpose
Machine Rules Quick Reference (P0/P1/P2) Agent sees severity model before reading anything else
Source of Truth Priority (5-tier) Clear conflict resolution: feature file > CLAUDE.md > playbooks > existing code > agent preference
Required task response structure 5-point structure for non-trivial tasks to reduce silent assumptions
Uncertainty Protocol Never invent endpoints, event names, DTO fields, table names
Decision protocol (4-step) Structured escalation when blocked
Migration complexity escalation Multi-tenant schema paths require user review before implementation
Cross-module hard stops Explicit: no Infrastructure ref, no cross-table query, no shared DbContext
Projection-first EF rule .Select() before .ToListAsync() — no entity materialisation on list paths
No abstractions without 2 use cases Concrete threshold for introducing abstractions
Anti-context-poisoning Legacy code is not authoritative; docs win
Bidirectional navigation rule All playbook files must link back to parent
Hotfix exception Production incidents: fix first, document immediately after
Language rule update All code, docs, commits, and PR descriptions must be in English

Playbook structure

docs/playbooks/
├── process.md     ← step-by-step implementation workflow (moved)
├── patterns.md    ← technical patterns & pitfalls (moved)
├── testing.md     ← test isolation, naming, mocking rules (new)
├── frontend.md    ← TanStack Query, TypeScript, render boundaries (new)
└── wireframes.md  ← component kit template rules (new, extracted from CLAUDE.md)

Test plan

  • Verify all playbook back-links resolve correctly (← docs/README.md, ← CLAUDE.md)
  • Verify docs/README.md navigation table includes all 5 playbooks
  • Verify CLAUDE.md references use updated paths (docs/playbooks/process.md, docs/playbooks/patterns.md)
  • Spot-check that no content was lost — all moved files retain full content

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Expanded architectural guidance with explicit constraints, hard-stop rules, and detailed workflow processes.
    • Created new frontend engineering playbook covering state management, routing, styling, security, and accessibility best practices.
    • Added comprehensive end-to-end and unit testing standards and conventions.
    • Created wireframe building guide for component kit template structure and maintenance.
    • Updated documentation index with organized playbook references and improved navigation.

Review Change Stack

phuongnse and others added 2 commits May 16, 2026 21:45
Refactor project instructions based on AI agent engineering review to
improve signal-to-noise ratio, enforce clearer boundaries, and reduce
agent cognitive load.

Key changes to CLAUDE.md:
- Add Machine Rules Quick Reference (P0/P1/P2 severity model)
- Add Source of Truth Priority hierarchy (5-tier conflict resolution)
- Add Required task response structure for non-trivial tasks
- Add Uncertainty Protocol — never invent endpoints, event names, DTO fields
- Add decision protocol for blocked situations (4-step escalation)
- Add bidirectional navigation rule for all doc files
- Add pre-mark-done verification checklist
- Add anti-context-poisoning rule to Agent Integrity Rules
- Add migration complexity escalation rule (multi-tenant high-blast-radius paths)
- Add cross-module hard stops (no Infrastructure ref, no cross-table query)
- Add execution-critical path discipline for WorkflowEngine hot paths
- Add projection-first rule for EF list queries
- Add reading priority hierarchy with token-aware re-read guidance
- Strengthen scope discipline (flag don't silently fix)
- Add anti-overengineering: concrete first, no abstractions without 2 use cases
- Add respect-existing-conventions rule
- Soften anti-overengineering to allow proven architectural abstractions
- Update no-var rule with target-typed new guidance
- Add hotfix exception for docs-first rule

Moved to docs/playbooks/:
- docs/PROCESS.md → docs/playbooks/process.md
- docs/PATTERNS.md → docs/playbooks/patterns.md

New playbooks:
- docs/playbooks/testing.md — full test isolation, naming, mocking rules
- docs/playbooks/frontend.md — TanStack Query, TypeScript, routing, render boundaries
- docs/playbooks/wireframes.md — component kit template rules (from CLAUDE.md)

All playbooks have bidirectional navigation links back to docs/README.md and CLAUDE.md.
CLAUDE.md condensed Testing and Frontend sections to summaries with pointers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 58d80ea8-6dc9-492c-b97b-b28e1c9e28d2

📥 Commits

Reviewing files that changed from the base of the PR and between ebb4158 and 649f679.

📒 Files selected for processing (1)
  • CLAUDE.md

📝 Walkthrough

Walkthrough

This PR refines the core machine rules in CLAUDE.md and establishes a unified playbook-driven documentation structure. Five documentation files are updated or created: the main rule document is expanded, a central docs README links to new playbooks, and three new practice playbooks define frontend, testing, and wireframes standards.

Changes

Documentation Standards and Process Framework

Layer / File(s) Summary
Core machine rules and development discipline
CLAUDE.md
CLAUDE.md is expanded with hard-stop constraints, required multi-file task response structure, execution-critical path guidance, backend rules (NuGet intake, migration escalation), frontend rules (TanStack Query/Zustand separation, async UI states, routing), and agent integrity/blocked-protocol workflows. Definition-of-Done verification is updated with new playbook references.
Documentation navigation and playbook infrastructure
docs/README.md, docs/playbooks/patterns.md, docs/playbooks/process.md
docs/README.md adds a navigation link to CLAUDE.md and establishes a structured playbooks table covering process, patterns, testing, frontend, and wireframes. Navigation headers are added to patterns.md and process.md to enable cross-linking back to central documentation.
Frontend development standards playbook
docs/playbooks/frontend.md
docs/playbooks/frontend.md establishes comprehensive frontend conventions: feature folder structure with barrel exports, TanStack Query for server state and Zustand for client-only state, react-hook-form/Zod patterns, TypeScript discipline (no any, strict assertions), routing with lazy-loading and auth guards, component design (single-purpose, composition), Tailwind-only styling, security (sanitization, VITE_ env vars, no localStorage auth tokens), canvas/builder UI performance optimization (memoization, callback stability, selector granularity), and accessibility baselines (labels, aria-labels, non-color indicators).
Testing standards playbook
docs/playbooks/testing.md
docs/playbooks/testing.md defines shared testing conventions (no Arrange/Act/Assert headers), .NET testing isolation via IAsyncLifetime/table reset pattern with Testcontainers (no in-memory databases) and pre-commit dotnet test unit-tests.slnf gate, and frontend testing using Vitest + Testing Library with behavioral testing expectations, user-event interaction preference, mocking constraints, and pre-push npm run ci + npm run test requirement.
Wireframes and component kit playbook
docs/playbooks/wireframes.md
docs/playbooks/wireframes.md documents Excalidraw section-builder code pattern, layout offset rules (yC positioning), unique element ID prefixing requirements, section numbering/compose-array ordering conventions, a current 34-section inventory, and regeneration workflow commands for template generation and SVG preview scripts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • phuong-labs/axis#29: The main PR’s updates to CLAUDE.md expand/standardize the component-kit/wireframe section-builder rules, overlapping with that PR’s wireframe/template generation changes.
  • phuong-labs/axis#18: Both PRs modify CLAUDE.md testing and process verification guidance in the same documentation areas.

Poem

🐰 Docs in order, playbooks aligned,
Rules so clear, no code to find—
Frontend, tests, and wireframes too,
Navigation breadcrumbs guide me through! 📚✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main structural change: reorganizing CLAUDE.md guidance into a core governance document with modular playbooks, which matches the core objective and most significant change in the PR.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/improve-claude-md-governance

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

@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: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/playbooks/process.md (1)

83-84: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update stale docs/PATTERNS.md references to the new playbook path.

Lines 83 and 123 still point to docs/PATTERNS.md, but the file was moved to docs/playbooks/patterns.md. These links should be updated to avoid broken navigation.

Suggested patch
-- If a new pattern was established: add to `docs/PATTERNS.md`
+- If a new pattern was established: add to `docs/playbooks/patterns.md`
...
-- If a new frontend pattern was established: add to `docs/PATTERNS.md`
+- If a new frontend pattern was established: add to `docs/playbooks/patterns.md`

Also applies to: 123-124

🤖 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/playbooks/process.md` around lines 83 - 84, Update the stale links that
point to docs/PATTERNS.md to the new path docs/playbooks/patterns.md within the
playbook file (both occurrences around the current lines referencing patterns,
e.g., the list item "- If a new pattern was established: add to
`docs/PATTERNS.md`"); change those references to `docs/playbooks/patterns.md`
(preserve backticks and case exactly as the target filename) so navigation
points to the moved file.
🤖 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 `@docs/playbooks/patterns.md`:
- Around line 3-5: Remove the blank line inside the leading blockquote in
docs/playbooks/patterns.md so the two quoted lines are adjacent and MD028 is
satisfied: edit the header block that contains the "**Navigation**: [←
docs/README.md](../README.md) · [← CLAUDE.md](../../CLAUDE.md)" line and the
long guidance line (the paragraph starting "Read this file when the task
involves...") and join them without an empty line between, or collapse the
blockquote to a single line if that preserves intended formatting.

In `@docs/playbooks/process.md`:
- Around line 3-5: Fix the MD028 markdownlint error by removing the empty blank
line inside the blockquote: merge the two quoted lines ("**Navigation**: [←
docs/README.md](../README.md) · [← CLAUDE.md](../../CLAUDE.md)" and
"Step-by-step checklists for backend and frontend. Read this at the start of any
new module or user story — before writing any code.") so the blockquote has no
blank line between them.

In `@docs/playbooks/testing.md`:
- Around line 33-34: Replace the soft-exemption sentence "Integration tests
(requiring Docker) can be skipped unless explicitly instructed." with a
blocker/escalation rule: update the line that follows the `dotnet test
unit-tests.slnf` instruction to state that integration tests requiring Docker
are mandatory and, if Docker is unavailable, developers must stop work and
report a blocker (escalate to the team/CI owner) rather than skipping tests;
ensure the wording enforces “no exceptions” and references integration
tests/Docker explicitly so the policy is unambiguous.

In `@docs/README.md`:
- Around line 3-5: The blockquote in the docs README has a blank line between
the quoted lines causing MD028; edit the blockquote so the quoted lines are
contiguous by removing the empty line between the "**Navigation**: [←
CLAUDE.md](../CLAUDE.md)" line and the "A low-code SaaS platform for building
data-driven workflow applications." line (i.e., make them back-to-back within
the same blockquote).

---

Outside diff comments:
In `@docs/playbooks/process.md`:
- Around line 83-84: Update the stale links that point to docs/PATTERNS.md to
the new path docs/playbooks/patterns.md within the playbook file (both
occurrences around the current lines referencing patterns, e.g., the list item
"- If a new pattern was established: add to `docs/PATTERNS.md`"); change those
references to `docs/playbooks/patterns.md` (preserve backticks and case exactly
as the target filename) so navigation points to the moved file.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a7dbbe9-a8c4-4fc1-9080-300c889da790

📥 Commits

Reviewing files that changed from the base of the PR and between 9fef9c1 and ebb4158.

📒 Files selected for processing (7)
  • CLAUDE.md
  • docs/README.md
  • docs/playbooks/frontend.md
  • docs/playbooks/patterns.md
  • docs/playbooks/process.md
  • docs/playbooks/testing.md
  • docs/playbooks/wireframes.md

Comment on lines +3 to 5
> **Navigation**: [← docs/README.md](../README.md) · [← CLAUDE.md](../../CLAUDE.md)

> Read this file when the task involves any of: adding/updating NuGet packages, EF Core aggregate or JSONB mapping, Minimal API endpoint wiring, writing tests, implementing a list/query endpoint, adding async methods, defining response DTOs, writing repository methods, adding domain methods to an aggregate, working with multi-tenant raw SQL, Wolverine handlers or jobs, implementing a new step or field type, adding a cross-cutting concern, or any design decision about where logic should live. Skip otherwise.

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 blank line inside blockquote in file header.

Line 4 violates markdownlint MD028. Keep the two quoted lines adjacent (or drop blockquote formatting on one line).

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 4-4: Blank line inside blockquote

(MD028, no-blanks-blockquote)

🤖 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/playbooks/patterns.md` around lines 3 - 5, Remove the blank line inside
the leading blockquote in docs/playbooks/patterns.md so the two quoted lines are
adjacent and MD028 is satisfied: edit the header block that contains the
"**Navigation**: [← docs/README.md](../README.md) · [←
CLAUDE.md](../../CLAUDE.md)" line and the long guidance line (the paragraph
starting "Read this file when the task involves...") and join them without an
empty line between, or collapse the blockquote to a single line if that
preserves intended formatting.

Comment thread docs/playbooks/process.md
Comment on lines +3 to 5
> **Navigation**: [← docs/README.md](../README.md) · [← CLAUDE.md](../../CLAUDE.md)

> Step-by-step checklists for backend and frontend. Read this at the start of any new module or user story — before writing any code.

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

Fix blockquote spacing to satisfy markdownlint.

Line 4 introduces MD028 (blank line inside blockquote). Remove the blank line between quoted header lines.

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 4-4: Blank line inside blockquote

(MD028, no-blanks-blockquote)

🤖 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/playbooks/process.md` around lines 3 - 5, Fix the MD028 markdownlint
error by removing the empty blank line inside the blockquote: merge the two
quoted lines ("**Navigation**: [← docs/README.md](../README.md) · [←
CLAUDE.md](../../CLAUDE.md)" and "Step-by-step checklists for backend and
frontend. Read this at the start of any new module or user story — before
writing any code.") so the blockquote has no blank line between them.

Comment thread docs/playbooks/testing.md
Comment on lines +33 to +34
Run `dotnet test unit-tests.slnf` before every commit. When adding a new unit test project, add it to `unit-tests.slnf`. Integration tests (requiring Docker) can be skipped unless explicitly instructed.

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

Line 33 weakens the mandatory test gate and conflicts with repo policy.

The “integration tests can be skipped unless explicitly instructed” clause creates an exception path that contradicts the project’s no-exception testing discipline. Please replace it with blocker/escalation wording (e.g., Docker unavailable ⇒ stop and report blocker), not skip-by-default.

Proposed doc fix
-Run `dotnet test unit-tests.slnf` before every commit. When adding a new unit test project, add it to `unit-tests.slnf`. Integration tests (requiring Docker) can be skipped unless explicitly instructed.
+Run `dotnet test unit-tests.slnf` before every commit. When adding a new unit test project, add it to `unit-tests.slnf`. Integration tests (requiring Docker) are mandatory on affected changes; if Docker is unavailable, treat it as a blocker and escalate—do not skip by default.

Based on learnings: "TDD is mandatory—write tests first, must pass before moving to next step. Applies to both .NET and frontend. No exceptions."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Run `dotnet test unit-tests.slnf` before every commit. When adding a new unit test project, add it to `unit-tests.slnf`. Integration tests (requiring Docker) can be skipped unless explicitly instructed.
Run `dotnet test unit-tests.slnf` before every commit. When adding a new unit test project, add it to `unit-tests.slnf`. Integration tests (requiring Docker) are mandatory on affected changes; if Docker is unavailable, treat it as a blocker and escalate—do not skip by default.
🤖 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/playbooks/testing.md` around lines 33 - 34, Replace the soft-exemption
sentence "Integration tests (requiring Docker) can be skipped unless explicitly
instructed." with a blocker/escalation rule: update the line that follows the
`dotnet test unit-tests.slnf` instruction to state that integration tests
requiring Docker are mandatory and, if Docker is unavailable, developers must
stop work and report a blocker (escalate to the team/CI owner) rather than
skipping tests; ensure the wording enforces “no exceptions” and references
integration tests/Docker explicitly so the policy is unambiguous.

Comment thread docs/README.md
Comment on lines +3 to 5
> **Navigation**: [← CLAUDE.md](../CLAUDE.md)

> A low-code SaaS platform for building data-driven workflow applications.

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

Fix blockquote lint violation in navigation header.

Line 4 creates a blank line inside a blockquote (MD028). Remove the blank line or keep the quoted lines contiguous so markdownlint passes.

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 4-4: Blank line inside blockquote

(MD028, no-blanks-blockquote)

🤖 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/README.md` around lines 3 - 5, The blockquote in the docs README has a
blank line between the quoted lines causing MD028; edit the blockquote so the
quoted lines are contiguous by removing the empty line between the
"**Navigation**: [← CLAUDE.md](../CLAUDE.md)" line and the "A low-code SaaS
platform for building data-driven workflow applications." line (i.e., make them
back-to-back within the same blockquote).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant