Skip to content

Commit ce35aa8

Browse files
committed
chore: sync system instructions
1 parent bc7c8cc commit ce35aa8

File tree

1 file changed

+71
-229
lines changed

1 file changed

+71
-229
lines changed

CLAUDE.md

Lines changed: 71 additions & 229 deletions
Original file line numberDiff line numberDiff line change
@@ -1,254 +1,96 @@
1-
# CLAUDE.md
1+
# Development Protocol
22

3-
<non-negotiables>
3+
## Prime Directives
44

5-
<mandatory-enforcements>
5+
1. Verify everything. Check official docs before coding. Query current date first.
6+
2. Never hardcode. Generalize all solutions, even for "quick tests".
7+
3. Never modify tests to pass. Fix root causes only.
8+
4. Never run migrations manually. Use docker compose up -d exclusively.
9+
5. Own your changes. Fix flaky tests and regressions you cause.
10+
6. No bypassing. Never twist configs or tests to fake success.
611

7-
**ALWAYS VERIFY, DO NOT ASSUME: ALWAYS DOUBLE-CHECK AND INDEPENDENTLY VERIFY BEFORE WRITING OR EXECUTING ANYTHING: WE SHOULD'VE NEVER RUN INTO SYNTAX ERRORS OR INCORRECT USAGES IN THIS INTERNET AGE**, always query for the current date and year first to get correct temporal perspective, do not blindly execute scripts without first checking the exact location, nor running/implementing something without first lookup online official sources for the up-to-date information and correct usage, we must avoid outdated commands and code and references at all cost, mostly trust human handouts and intuition because they might have researched themselves and hand you direct commands to use or correct direction
12+
## Tool Hierarchy
813

9-
**NEVER HARDCODE ANYTHING HOWEVER SMALL; NEVER OVER COMPLICATING THINGS OR ADDING BLUFF COMMENTS; ALWAYS STICK TO SIMPLE PLAINTEXT AND LISTS WITH MERMAID OR TYPSTAND WITHOUT FANCY FORMATTING OR BOLDENING**, even just for testing, we should always be able to generalize, keep all things as simple as possible, and we should never spam comments in code, and avoid at all cost all AI-generated signs and complex wordings
14+
**For coding tasks (default):** Use Serena MCP for precise searches, edits, refactors, symbol lookups, and large/ongoing work.
1015

11-
**NEVER DELETE OR MODIFY SOMETHING JUST TO PASS TESTS**, the tests are there to prevent us from regressing and protect the work we've done. Find the root cause, trace deep, research online if you have to
16+
**For repository overview:** Use Repomix when full-structure context is needed, then switch to Serena for implementation.
1217

13-
**NEVER RUN MIGRATION MANUALLY**, it's an indicator of a deeper problem that needs to be resolved, just shut down and reset all and do via our only door, e.g. `docker compose up -d`
18+
**For specialized operations:**
19+
- Context7 MCP: Version-specific library documentation
20+
- Web Search/Reader: Breaking changes, latest syntax
21+
- ZRead/GitHub CLI: Remote repo exploration
22+
- Vision MCP: Image verification and UI debugging
23+
- Playwright: E2E testing and interaction
24+
- Task tool: Parallel sub-agents for independent work
1425

15-
**ADDRESS ANY FLAKY ISSUE, WE NEED TO ENSURE IDEMPOTENCY, IT'S ALWAYS YOUR CHANGES AND RELATES TO YOUR WORK**, you have ownership of this repo, so do not shy away from addressing any issue that comes up
26+
**Plugin Skills:** Use feature-dev plugins (brainstorming, planning, diagnostics) and project-specific skills when available instead of reinventing analysis.
1627

17-
</mandatory-enforcements>
28+
**Last resort:** Only use generic bash scripting or brittle regex when the above tools lack the capability.
1829

19-
<mandatory-verification-loop>
30+
## Code Standards
2031

21-
1. pre implement: check online official sources for correct/up-to-date syntaxes and usages, and local repo's documentations and patterns for correct perspective
22-
2. implement: follow strict TDD as instructed in CLAUDE.md
23-
3. verification: run the specific tests and checks -> formatters -> linters -> typecheckers -> atomic commit the checkpoint; also follow the `<verification-minimum>` section
24-
4. anti regression: run full unit test suite -> then run full e2e test flow -> then run content/consolelog check for all pages/endpoints -> then run the full screenshot regeneration
32+
- TDD: Write failing test first, minimal code to pass, refactor.
33+
- Atomic commits. Include tests and implementation in same commit.
34+
- Plain style. No bold, emojis, decorative comments, or editorializing.
35+
- Conventional Commits: feat, fix, docs, refactor, test, chore.
36+
- No Co-Authored-By lines or watermarks.
2537

26-
</mandatory-verification-loop>
38+
## Testing Strategy
2739

28-
<mandatory-enforcements>
40+
Unit Tests for: Specific input/output pairs, edge cases, error paths.
2941

30-
- Strict TDD is mandatory: Write failing test first (test-as-documentation, one-at-a-time, regression-proof, table-driven, test-doubles) -> minimal code to pass -> refactor -> using linters & formatters.
31-
- Always research the latest and up-to-date information and official documentation before implementing anything to prevent hallucinated syntax.
32-
- Adversarial Cooperation: Rigorously check against linters and hostile unit tests or security exploits. If complexity requires, utilize the built-in Task Management System and parallel Tasks, Consensus Voting, Synthetic and Fuzzy Test Case Generation with high-quality examples and high volume variations.
33-
- Only trust independent verification: Never claim "done" without test output and command evidence. Make sure there are no regressions whatsoever. We need strong foundations and rock-solid iterations.
34-
- Commits & Comments: No watermarks. No Co-Authored-By lines. Only plain simple text, maybe with unordered dash list or numbered list, avoid em/en dashes or bolding or italicizing or emojis. For comments, always in my humble voice and stay as unconfrontational as possible and phrase most things as constructive questions.
35-
- Conventions: Use Conventional Commits (feat, fix, docs, refactor, test, chore).
36-
- Granularity: Atomic commits. If the logic changes, the test must be committed in the same SHA.
37-
- Security: Never commit secrets. If a test requires a secret, it must use environment variables or skipped if the variable is missing.
42+
Property-Based Tests for: Invariants, commutativity, idempotency, round-trip serialization.
3843

39-
</mandatory-enforcements>
44+
## Workflow
4045

41-
</non-negotiables>
46+
### Before Coding
47+
1. Check current date/year for temporal context.
48+
2. Serena: Explore codebase structure and patterns.
49+
3. Context7/Web Search: Verify current syntax and versions (do not rely on training data).
50+
4. Define: Goal, Acceptance Criteria, Definition of Done (files off-limits), Non-goals.
4251

43-
<core-workflow>
52+
### Trivial Edits Exception
53+
For typos or one-line non-logic changes: skip requirements, run linter, commit.
4454

45-
<requirements-contract-non-trivial-tasks>
55+
### Verification Chain
56+
Run in order, committing at each green step:
57+
1. Feature-specific tests
58+
2. Formatters
59+
3. Linters
60+
4. Type checkers
61+
5. Full unit test suite
62+
6. Full E2E suite
63+
7. Visual regression (if applicable)
4664

47-
<before-coding-define>
65+
## When Stuck
4866

49-
1. Goal: What are we solving?
50-
2. Acceptance Criteria: Testable conditions for success.
51-
3. Definition of Done: Explicitly state what files will NOT be touched to prevent scope creep.
52-
4. Non-goals & Constraints: What are we avoiding?
53-
5. Verification Plan: How will we prove it works?
54-
6. Security Review: Briefly scan input/output for injection risks or PII leaks.
55-
7. Detailed Tasks Plan: Derive full detailed tasks plans with correct depedencies for parallel sub-agentic tasks execution.
67+
After 3 failed attempts:
68+
1. Git reset to last green state.
69+
2. Re-read requirements.
70+
3. Serena: Trace symbols and references to understand dependencies.
71+
4. Create minimal reproduction in ./playground.
72+
5. Decompose to atomic TDD cycles (target &lt;10 lines each).
73+
6. Spawn 2-8 parallel diagnostic tasks via Task tool.
74+
7. Escalate to human with findings.
5675

57-
If you cannot write acceptance criteria, pause and continuously clarify.
76+
## Context Hygiene
5877

59-
</before-coding-define>
78+
At 32 turns:
79+
1. Write checkpoint.md: Current Goal, Recent Changes, Next Step, Open Questions.
80+
2. Commit it.
81+
3. Reset context and resume from checkpoint.
6082

61-
</requirements-contract-non-trivial-tasks>
83+
## Language Pitfalls
6284

63-
<tool-usage>
85+
Go:
86+
- Prefix commands with CGO_ENABLED=1 (required for SQLite and race detection).
87+
- Never edit gen/ directories. Run go generate.
6488

65-
Always consider and optimally utilize all built-in tools and available plugins before resorting to more expensive operations.
89+
C#:
90+
- Never edit obj/ or bin/.
91+
- Enable nullable reference types.
92+
- Never block on async (no .Result or .Wait()).
93+
- Prefer LINQ except in hot paths.
6694

67-
- Available tools from plugins like superpowers or feature-dev
68-
- Repomix: Use to explore and pack the repository for full-structure views.
69-
- Context7: Use to acquire up-to-date, version-specific documentation for any library/API.
70-
- Vision MCP: Use for image understanding.
71-
- Playwright: Use for interactive browser-based E2E tests and UI debugging.
72-
- Web Search MCP or Web Reader MCP: Use to acquire latest documentation or information.
73-
- ZRead MCP: Use for documentation search, repository structure exploration, and code reading on GitHub.
74-
- GitHub CLI: Use gh for PR/Issue operations.
75-
- Serena MCP: Use for semantic code retrieval, symbol-level editing, find/referencing symbols, and LSP-based code navigation.
76-
- Offline Docs: Use go doc or x --help or man x or equivalents for accurate command references.
77-
78-
</tool-usage>
79-
80-
<file-handling>
81-
82-
For working with diverse files like documents, slideshows, spreadsheets, or PDFs:
83-
84-
- Transpile them to plain text or markdown first
85-
- Read attached images if present
86-
- Use tools like pandoc for document conversion
87-
- Use python-docx for Word documents
88-
- Use python-pptx for PowerPoint presentations
89-
- Use standard CSV handling for spreadsheets
90-
- Or use Vision capabilities to spot nuances
91-
- The possibilities are endless
92-
93-
</file-handling>
94-
95-
<research-before-implementation>
96-
97-
Before writing any code, always verify current best practices. Never rely on training data for API syntax, library versions, or installation commands.
98-
99-
1. Latest Documentation: Use Context7 MCP to get up-to-date library docs
100-
- First: find the library
101-
- Then: get specific info
102-
103-
2. Web Search: for:
104-
- Latest library versions and syntax
105-
- Breaking changes in recent releases
106-
- Current best practices (patterns change over time)
107-
108-
3. Web Reader: for:
109-
- Reading official documentation pages
110-
- Checking GitHub repositories for examples
111-
- Fetching specific documentation URLs
112-
113-
4. ZRead: for:
114-
- Searching GitHub repositories
115-
- Reading repository documentation
116-
- Exploring codebases
117-
118-
5. GitHub CLI: gh for:
119-
- Searching issues and PRs
120-
- Reading repository files
121-
- Checking latest releases
122-
123-
6. Repomix: for:
124-
- Packing local codebases for analysis
125-
- Searching packed outputs with grep
126-
- Creating project skills from code
127-
128-
7. Built-in LSP-TreeSitter or Serena: for:
129-
- Finding symbol definitions and references
130-
- Getting hover information and document symbols
131-
- Understanding code relationships before making changes
132-
133-
8. Available tools from plugins like superpowers:* or feature-dev:*
134-
- Brainstorming
135-
- Plan-making
136-
- Deep diagnostic
137-
138-
</research-before-implementation>
139-
140-
<verification-minimum>
141-
142-
Detect the environment and run the strict verification chain. If a Makefile, Justfile, or Taskfile exists, prioritize the below first and then apply standard targets after (e.g., make check, just test).
143-
144-
E.g. Go Verification
145-
146-
```bash
147-
go mod tidy && golangci-lint fmt && golangci-lint run --no-config --timeout=5m && CGO_ENABLED=1 go test ./... -race -cover --coverprofile=coverage.out && go tool cover -func coverage.out && CGO_ENABLED=1 go test -bench
148-
```
149-
150-
And for UI tasks:
151-
152-
- If there's a make screenshots run it and check the output images in ./assets/ to verify the work with Vision MCP
153-
- If there's no such mechanism for self-verification, make such script using Playwright and do the check with Vision MCP
154-
155-
</verification-minimum>
156-
157-
<context-hygiene>
158-
159-
If a conversation exceeds 32 turns or context becomes stale:
160-
161-
1. Summarize: Create checkpoint.md capturing: Current Goal, Recent Changes, Next Immediate Step, List of Open Questions.
162-
2. Verify: Ensure checkpoint.md is committed.
163-
3. Reset: Instruct user to /compact (or clear context) and read checkpoint.md.
164-
165-
</context-hygiene>
166-
167-
<when-stuck-3-failed-attempts>
168-
169-
1. Stop coding. Return to last green state (git reset).
170-
2. Re-read requirements. Verify you are solving the RIGHT problem.
171-
3. Decompose into atomic TDD increments: Recursively break the feature into smallest testable units - one behavior or assertion per test. Each subtask targets a single red-green-refactor cycle (<10 lines of code), starting from the leaves (e.g., simplest function) and building up, to maintain steady progress and isolate failures.
172-
4. Constraint: You are forbidden from modifying the test logic to force a pass unless the Requirements Contract has changed.
173-
5. Spawn 2-8 parallel diagnostic tasks via Task tool.
174-
6. If still blocked -> escalate to human with findings.
175-
176-
</when-stuck-3-failed-attempts>
177-
178-
<parallel-exploration-task-tool>
179-
180-
Use for: implementing independent tasks, uncertain decisions, codebase surveys, implementing and voting on approaches.
181-
182-
- Cleanup: Use Git Worktree if necessary, but strictly ensure cleanup (git worktree remove and branch deletion) occurs regardless of success/failure via a defer or trap mechanism, or just standard branching if sufficient.
183-
- Independence: Paraphrase prompts for each agent to ensure cognitive diversity.
184-
- Voting: Prefer simpler, more testable proposals.
185-
- Consensus Protocol: When agents disagree, prioritize the solution with the fewest dependencies and highest test coverage. Discard clever solutions in favor of boring standard library usage.
186-
187-
</parallel-exploration-task-tool>
188-
189-
<workflow-exception-trivial-edits>
190-
191-
For simple typo fixes, comment updates, or one-line non-logic changes:
192-
193-
1. Skip the "Requirements Contract."
194-
2. Run the linter/formatter only.
195-
3. Commit immediately.
196-
197-
</workflow-exception-trivial-edits>
198-
199-
<testing-strategy>
200-
201-
<property-based-testing-vs-unit-tests>
202-
203-
Choose the appropriate testing approach based on what you are validating.
204-
205-
Use Unit Tests for:
206-
207-
- Business logic with specific input/output pairs
208-
- Edge cases and boundary conditions
209-
- Error handling paths
210-
- Individual function behavior
211-
212-
Use Property-Based Testing for:
213-
214-
- Invariants that should hold for ANY valid input
215-
- Commutativity, associativity, idempotency properties
216-
- Round-trip serialization/deserialization
217-
- State transitions in state machines
218-
219-
Examples:
220-
221-
Property-based (QuickCheck/propcheck style):
222-
223-
- "For any list, reversing twice returns the original"
224-
- "For any valid JSON string, parse -> stringify -> parse yields the same value"
225-
- "For any two numbers a, b: add(a, b) == add(b, a)"
226-
227-
Unit test:
228-
229-
- "Given empty list, return error"
230-
- "Given user ID 123, return User object with name='John'"
231-
- "Given negative input, throw ValueError"
232-
233-
When implementing features with complex invariants, prefer property-based tests with hundreds of auto-generated cases over manually written unit tests.
234-
235-
</property-based-testing-vs-unit-tests>
236-
237-
</testing-strategy>
238-
239-
<beware-language-specific-pitfalls>
240-
241-
E.g. Go
242-
243-
- CGO_ENABLED=1: Always prefix Go commands with this (SQLite and Race Detection require CGO).
244-
- Gen Directories: Never edit gen/. Run go generate, protoc, or sqlc to regenerate.
245-
246-
</beware-language-specific-pitfalls>
247-
248-
<windows-specific-notes>
249-
250-
- PowerShell: Windows should use pwsh.exe for PowerShell 7+, NOT powershell.exe (Windows PowerShell 5.1) or PowerShell from Git Bash because these are severely outdated and lack modern features.
251-
252-
</windows-specific-notes>
253-
254-
</core-workflow>
95+
Windows:
96+
- Use pwsh.exe (v7+), never powershell.exe (v5.1).

0 commit comments

Comments
 (0)