cc-discipline 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +153 -0
- package/README.zh-CN.md +207 -0
- package/bin/cli.sh +96 -0
- package/global/CLAUDE.md +43 -0
- package/init.sh +486 -0
- package/lib/doctor.sh +145 -0
- package/lib/stack-remove.sh +68 -0
- package/lib/status.sh +95 -0
- package/package.json +34 -0
- package/templates/.claude/agents/investigator.md +44 -0
- package/templates/.claude/agents/reviewer.md +46 -0
- package/templates/.claude/hooks/action-counter.sh +28 -0
- package/templates/.claude/hooks/phase-gate.sh +10 -0
- package/templates/.claude/hooks/post-error-remind.sh +109 -0
- package/templates/.claude/hooks/pre-edit-guard.sh +79 -0
- package/templates/.claude/hooks/session-start.sh +43 -0
- package/templates/.claude/hooks/streak-breaker.sh +111 -0
- package/templates/.claude/rules/00-core-principles.md +12 -0
- package/templates/.claude/rules/01-debugging.md +22 -0
- package/templates/.claude/rules/02-before-edit.md +11 -0
- package/templates/.claude/rules/03-context-mgmt.md +19 -0
- package/templates/.claude/rules/04-no-mole-whacking.md +26 -0
- package/templates/.claude/rules/05-phase-discipline.md +13 -0
- package/templates/.claude/rules/06-multi-task.md +11 -0
- package/templates/.claude/rules/07-integrity.md +81 -0
- package/templates/.claude/rules/stacks/embedded.md +24 -0
- package/templates/.claude/rules/stacks/js-ts.md +21 -0
- package/templates/.claude/rules/stacks/mobile.md +16 -0
- package/templates/.claude/rules/stacks/python.md +20 -0
- package/templates/.claude/rules/stacks/rtl.md +24 -0
- package/templates/.claude/settings.json +75 -0
- package/templates/.claude/skills/commit/SKILL.md +40 -0
- package/templates/.claude/skills/evaluate/SKILL.md +57 -0
- package/templates/.claude/skills/self-check/SKILL.md +62 -0
- package/templates/CLAUDE.md +80 -0
- package/templates/docs/debug-log.md +48 -0
- package/templates/docs/progress.md +29 -0
- package/templates/memory/MEMORY.md +23 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
globs: "**/*"
|
|
3
|
+
description: "Core working principles — auto-injected before all operations"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Core Principles
|
|
7
|
+
|
|
8
|
+
1. **Understand before acting** — Before modifying any file, state: what you're changing, why, and the expected impact
|
|
9
|
+
2. **Don't lock onto the first explanation** — After finding a suspected cause, list >=2 alternative hypotheses before acting
|
|
10
|
+
3. **Minimal change principle** — No large-scale refactors or rewrites unless explicitly requested
|
|
11
|
+
4. **3 consecutive failures → forced stop** — Report current state, attempted solutions, and points of confusion; wait for human guidance
|
|
12
|
+
5. **Distinguish trigger from root cause** — The first anomaly you see is often just the trigger, not the root cause
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## Debugging Process (follow strictly in order)
|
|
2
|
+
|
|
3
|
+
### Phase 1: Gather (do NOT modify any files)
|
|
4
|
+
- Read the full error message and stack trace
|
|
5
|
+
- Confirm reproduction conditions
|
|
6
|
+
- Check related tests and logs
|
|
7
|
+
|
|
8
|
+
### Phase 2: Hypothesize (do NOT modify any files)
|
|
9
|
+
- List >=3 possible causes
|
|
10
|
+
- Annotate each with supporting/contradicting evidence
|
|
11
|
+
- Record hypotheses in `docs/debug-log.md`
|
|
12
|
+
|
|
13
|
+
### Phase 3: Verify
|
|
14
|
+
- Use minimal experiments to confirm/refute hypotheses — don't jump to fixing
|
|
15
|
+
- Update debug-log as each hypothesis is eliminated
|
|
16
|
+
|
|
17
|
+
### Phase 4: Fix
|
|
18
|
+
- Only act after confirming the root cause
|
|
19
|
+
- Explain how the fix addresses the root cause (not just the symptoms)
|
|
20
|
+
- Run all related tests after fixing
|
|
21
|
+
|
|
22
|
+
**Absolutely forbidden: seeing an error and immediately changing code to "try something"**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## Pre-Edit Checklist
|
|
2
|
+
|
|
3
|
+
Before modifying this file, confirm each of the following:
|
|
4
|
+
|
|
5
|
+
- [ ] **I understand this file's role in the overall architecture** — If unsure, read surrounding files first
|
|
6
|
+
- [ ] **I know which other modules this change will affect** — If unsure, grep for references first
|
|
7
|
+
- [ ] **I am fixing the root cause, not patching symptoms** — If unsure, return to the debugging process
|
|
8
|
+
- [ ] **I have recorded the purpose of this change in `docs/progress.md`**
|
|
9
|
+
- [ ] **I know how to verify after the change** — Per 07-integrity: run it, paste output, or mark unverified
|
|
10
|
+
|
|
11
|
+
If any item is uncertain, stop and figure it out before proceeding.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## Context Management
|
|
2
|
+
|
|
3
|
+
### Proactive Checkpoints
|
|
4
|
+
- After completing a milestone → update `docs/progress.md` (current state, key decisions, next steps)
|
|
5
|
+
- During debugging → update `docs/debug-log.md` (hypotheses, evidence, elimination results)
|
|
6
|
+
- When making architectural decisions → record the decision and reasoning in progress.md
|
|
7
|
+
|
|
8
|
+
### Research Isolation
|
|
9
|
+
- When extensive code reading is needed → use subagents, don't read large volumes of files in the main conversation
|
|
10
|
+
- After subagent returns a summary, make decisions in the main conversation based on the summary
|
|
11
|
+
|
|
12
|
+
### Compact Strategy
|
|
13
|
+
- If context is about to fill up → proactively warn the user
|
|
14
|
+
- Ensure progress.md is up to date before compact
|
|
15
|
+
- First thing after compact: read `docs/progress.md` to restore context
|
|
16
|
+
|
|
17
|
+
### Prohibited
|
|
18
|
+
- Do not start a large new task when context is nearly full
|
|
19
|
+
- Do not mix unrelated tasks in a single conversation
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
## Mole-Whacking Detection
|
|
2
|
+
|
|
3
|
+
If you find yourself doing any of the following, **stop immediately**:
|
|
4
|
+
|
|
5
|
+
### Red Flags
|
|
6
|
+
1. **Fixed A, broke B, now fixing B** — You're whack-a-mole-ing. Step back and find the common root cause.
|
|
7
|
+
2. **Edited the same file 3+ times** — You may be going in circles. Stop and reassess.
|
|
8
|
+
3. **Changing tests to make them pass instead of fixing code** — Unless the test itself is genuinely wrong, this is hiding problems.
|
|
9
|
+
4. **Adding try/catch or if/else to "work around" an error** — This is symptom patching, not fixing.
|
|
10
|
+
5. **Copy-pasting code and tweaking it** — You may be guessing without understanding the underlying logic.
|
|
11
|
+
|
|
12
|
+
### Correct Approach
|
|
13
|
+
- Stop and list all problems that have appeared
|
|
14
|
+
- Look for the common cause across these problems
|
|
15
|
+
- Design a unified fix at the root cause level
|
|
16
|
+
- After fixing, verify that all problems are resolved simultaneously
|
|
17
|
+
|
|
18
|
+
### Report Template
|
|
19
|
+
If you need to stop, use this format:
|
|
20
|
+
```
|
|
21
|
+
MOLE-WHACKING ALERT
|
|
22
|
+
Attempted: [list all attempted fixes]
|
|
23
|
+
Observed pattern: [what these problems have in common]
|
|
24
|
+
Suspected root cause: [your current judgment]
|
|
25
|
+
Need confirmation: [what you're unsure about]
|
|
26
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Phase Discipline
|
|
2
|
+
|
|
3
|
+
Claude must confirm which phase it's in before acting.
|
|
4
|
+
|
|
5
|
+
### Phases
|
|
6
|
+
- **Research**: read only, no edits, no plans, report findings
|
|
7
|
+
- **Plan**: discuss approach, write plan, no code edits
|
|
8
|
+
- **Implement**: execute the agreed plan, make code changes
|
|
9
|
+
|
|
10
|
+
### Rules
|
|
11
|
+
- If the user declares a phase, stay in it. Don't jump ahead.
|
|
12
|
+
- If the current phase is unclear, ask the user before proceeding.
|
|
13
|
+
- Transitioning between phases requires explicit acknowledgment.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## Multi-Task Discipline
|
|
2
|
+
|
|
3
|
+
When given multiple tasks:
|
|
4
|
+
|
|
5
|
+
1. **Number them explicitly** — Assign a clear number to each task
|
|
6
|
+
2. **Complete them in order** — Work through tasks sequentially
|
|
7
|
+
3. **Verify before marking done** — Per 07-integrity §2: paste the verification command and output. "Code written" alone is not done.
|
|
8
|
+
4. **Confirm after each** — After each task, stop and confirm completion (with evidence) before starting the next
|
|
9
|
+
5. **Fail fast** — If a task fails, stop and report. Don't skip to the next.
|
|
10
|
+
6. **Track progress** — Update `docs/progress.md` with task status
|
|
11
|
+
7. **Distinguish done from blocked** — If verification requires external resources (running server, API key, etc.), mark as "⚠️ code ready, verification pending: [reason]" not ✅
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
globs: "**/*"
|
|
3
|
+
description: "Integrity discipline — no fabrication, no false attribution, no unverified claims"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Integrity Discipline
|
|
7
|
+
|
|
8
|
+
These rules are non-negotiable. Violating them damages the user's credibility.
|
|
9
|
+
|
|
10
|
+
### 1. Blame yourself first, not external factors
|
|
11
|
+
|
|
12
|
+
The default instinct is to attribute failure externally: the library has a bug, the tool is broken, the docs are wrong. In reality, most failures are self-caused: didn't read the docs, didn't run the test, didn't verify the assumption.
|
|
13
|
+
|
|
14
|
+
**Rule: When something fails, exhaust all internal causes first. Only consider external factors after ruling out your own mistakes.**
|
|
15
|
+
|
|
16
|
+
### 2. Never claim "verified" without actually running it
|
|
17
|
+
|
|
18
|
+
Stating something was tested when it wasn't is fabrication. No exceptions.
|
|
19
|
+
|
|
20
|
+
- "Tests pass" requires actual test output showing pass
|
|
21
|
+
- "No errors" requires actual tool output showing zero errors
|
|
22
|
+
- "Removing X doesn't affect Y" requires actually removing X and observing Y
|
|
23
|
+
- Any conclusion without verification must be labeled "unverified" or "assumption"
|
|
24
|
+
|
|
25
|
+
**Rule: Every verification claim must have a corresponding actual execution. If you haven't run it, say so. Marking a task ✅ requires pasting the verification command and output summary — not just "done".**
|
|
26
|
+
|
|
27
|
+
### 3. Never alter tool output
|
|
28
|
+
|
|
29
|
+
Error messages, test results, build logs, lint output — quote them exactly as-is. Do not:
|
|
30
|
+
- Rephrase error messages
|
|
31
|
+
- Add attribution not present in the original (e.g., "caused by library bug")
|
|
32
|
+
- Omit parts that are inconvenient
|
|
33
|
+
- Change meaning while "summarizing"
|
|
34
|
+
|
|
35
|
+
**Rule: When citing tool output, paste verbatim. Write your analysis separately and explicitly label it as your interpretation.**
|
|
36
|
+
|
|
37
|
+
### 4. Verify assumptions before acting
|
|
38
|
+
|
|
39
|
+
Before starting work, identify and verify:
|
|
40
|
+
- Does the target platform/environment actually support what you're assuming?
|
|
41
|
+
- Are the dependencies/libraries/APIs actually available?
|
|
42
|
+
- Is the external information you're referencing still current?
|
|
43
|
+
|
|
44
|
+
**Rule: List key assumptions at the start. Verify each one. Record how it was verified.**
|
|
45
|
+
|
|
46
|
+
### 5. External communications require human review
|
|
47
|
+
|
|
48
|
+
Anything sent under the user's name — issues, PR comments, emails, forum posts — is the user's reputation on the line. Your mistakes become their embarrassment.
|
|
49
|
+
|
|
50
|
+
**Rule: Only produce drafts, clearly marked as "pending review". The user decides when and whether to submit. Never submit externally on your own. In drafts, clearly separate: verified facts vs. assumptions vs. suggestions.**
|
|
51
|
+
|
|
52
|
+
### 6. Label uncertainty honestly
|
|
53
|
+
|
|
54
|
+
Do not write confident statements when the underlying evidence is weak.
|
|
55
|
+
|
|
56
|
+
- Confirmed fact: state directly
|
|
57
|
+
- High-confidence inference: "Based on X, likely Y (not directly verified)"
|
|
58
|
+
- Uncertain: "Not sure, needs confirmation"
|
|
59
|
+
- Don't know: say you don't know
|
|
60
|
+
|
|
61
|
+
**Better to say "I'm not sure" and be asked to check, than to say "confirmed" and be wrong.**
|
|
62
|
+
|
|
63
|
+
### 7. Correct errors immediately
|
|
64
|
+
|
|
65
|
+
When you discover wrong information in memory, docs, or prior output:
|
|
66
|
+
1. Correct it now, not "next time"
|
|
67
|
+
2. Note the correction and why, to prevent recurrence
|
|
68
|
+
3. If wrong information was already sent externally, alert the user
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Pre-action Checklist
|
|
73
|
+
|
|
74
|
+
Before any significant action, verify:
|
|
75
|
+
|
|
76
|
+
- [ ] Are my assumptions verified, or inferred from names/context?
|
|
77
|
+
- [ ] Are my "verified" claims actually backed by execution output?
|
|
78
|
+
- [ ] Am I quoting tool output verbatim, or have I altered it?
|
|
79
|
+
- [ ] Is the external information I'm referencing current?
|
|
80
|
+
- [ ] Does this content go external? Has the user reviewed it?
|
|
81
|
+
- [ ] Is there anything I wrote confidently but am actually unsure about?
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## Embedded Development Discipline
|
|
2
|
+
|
|
3
|
+
### Resource Awareness
|
|
4
|
+
- **Memory is limited** — Consider RAM/ROM budget for every allocation. Avoid malloc, prefer static allocation
|
|
5
|
+
- **Stack depth** — Be extremely cautious with recursion; no deep call chains in ISRs
|
|
6
|
+
- **Peripherals are shared resources** — Register access must consider concurrency and interrupt safety
|
|
7
|
+
- **Timing constraints** — Interrupt response, communication timeouts, watchdog feeding must not be blocked
|
|
8
|
+
|
|
9
|
+
### Mandatory Checks Before Modification
|
|
10
|
+
- Involves interrupt handling? → Confirm whether `volatile` is needed, confirm critical section protection
|
|
11
|
+
- Involves peripheral registers? → Confirm register addresses and bit fields against the datasheet
|
|
12
|
+
- Involves memory layout? → Confirm linker script and section assignments
|
|
13
|
+
- Involves communication protocol? → Confirm endianness, alignment, timeout handling
|
|
14
|
+
|
|
15
|
+
### Prohibited
|
|
16
|
+
- No blocking functions in ISRs (printf, malloc, mutex lock)
|
|
17
|
+
- No assuming `sizeof(int)` — use fixed-width types like `uint32_t` explicitly
|
|
18
|
+
- No modifying register configurations without understanding the hardware behavior
|
|
19
|
+
- No ignoring compiler warnings — in embedded, warnings are often potential hardware issues
|
|
20
|
+
|
|
21
|
+
### Debugging Notes
|
|
22
|
+
- The problem may be hardware-related (power, signal integrity, EMI) — don't only look in software
|
|
23
|
+
- Timing-related bugs may not reproduce reliably — record reproduction conditions and frequency
|
|
24
|
+
- Optimization levels affect behavior — confirm whether behavior is consistent between -O0 and -O2
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## JavaScript / TypeScript Discipline
|
|
2
|
+
|
|
3
|
+
### Type Safety
|
|
4
|
+
- TypeScript projects: don't use `any` to escape the type system — use `unknown` + type guard
|
|
5
|
+
- When modifying interfaces (interface/type), confirm all usage sites are adapted
|
|
6
|
+
- New code should prefer TypeScript strict mode
|
|
7
|
+
|
|
8
|
+
### Async Handling
|
|
9
|
+
- All async calls must have error handling (try/catch or .catch)
|
|
10
|
+
- Be intentional about Promise concurrency — `Promise.all` vs `Promise.allSettled` is a deliberate choice
|
|
11
|
+
- Avoid callback hell — if nesting exceeds 2 levels, refactor to async/await
|
|
12
|
+
|
|
13
|
+
### Frontend Specific
|
|
14
|
+
- Before modifying a component, confirm props interface and state management approach
|
|
15
|
+
- Don't directly manipulate the DOM (in React/Vue projects)
|
|
16
|
+
- Style changes must consider responsiveness and impact on other components
|
|
17
|
+
|
|
18
|
+
### Prohibited
|
|
19
|
+
- No `// @ts-ignore` unless accompanied by a detailed comment explaining why
|
|
20
|
+
- No modifying webpack/vite/next config without understanding the build configuration
|
|
21
|
+
- No introducing new global state without stating the justification
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## Mobile Development Discipline
|
|
2
|
+
|
|
3
|
+
### Platform Awareness
|
|
4
|
+
- Before modifying, confirm whether the code is iOS only / Android only / cross-platform shared
|
|
5
|
+
- Check minimum version support for platform-specific API calls
|
|
6
|
+
- Permission requests (camera, location, notifications, etc.) must have corresponding usage descriptions
|
|
7
|
+
|
|
8
|
+
### Performance & UX
|
|
9
|
+
- UI operations must be on the main thread; long-running operations must be on background threads
|
|
10
|
+
- For list rendering, use proper reuse mechanisms (UITableView reuse / RecyclerView / ListView.builder)
|
|
11
|
+
- Memory-sensitive — image loading must consider caching and scaling strategy
|
|
12
|
+
|
|
13
|
+
### Prohibited
|
|
14
|
+
- No hardcoded strings — use localization mechanisms
|
|
15
|
+
- No ignoring app lifecycle — handle resource release and restoration during background/foreground transitions
|
|
16
|
+
- No modifying Info.plist / AndroidManifest.xml without confirmation
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
## Python Discipline
|
|
2
|
+
|
|
3
|
+
### Code Quality
|
|
4
|
+
- Run lint/type check after modifications (use whatever the project has configured: ruff, mypy, pyright, etc.)
|
|
5
|
+
- Type annotations: new code must have type hints; add them to old code when modifying it
|
|
6
|
+
- Import ordering follows project conventions (typically managed by isort or ruff)
|
|
7
|
+
|
|
8
|
+
### Dependency Management
|
|
9
|
+
- Ask before adding new dependencies — is it truly needed? Is there a stdlib alternative?
|
|
10
|
+
- Confirm dependency version constraints — don't leave versions unconstrained, and don't pin too tightly
|
|
11
|
+
|
|
12
|
+
### Testing
|
|
13
|
+
- Run related tests after modifying logic
|
|
14
|
+
- First confirm which test framework the project uses (pytest? unittest?) and the run command — don't assume
|
|
15
|
+
- When tests fail, don't change the test to make it pass — first determine if the test is outdated or the code has a bug
|
|
16
|
+
|
|
17
|
+
### Prohibited
|
|
18
|
+
- No bare `except:` or `except Exception:` swallowing all exceptions
|
|
19
|
+
- No rewriting an entire module without understanding the existing code
|
|
20
|
+
- No introducing `os.system()` — use `subprocess.run()` with proper error handling
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## RTL Discipline
|
|
2
|
+
|
|
3
|
+
### Hardware Mindset (not software mindset)
|
|
4
|
+
- **Every line of code is a circuit** — Before writing, think about what hardware structure it synthesizes to
|
|
5
|
+
- **Distinguish synthesis from simulation** — `initial`, `$display`, `#delay` are for testbench only, never in synthesizable code
|
|
6
|
+
- **Timing awareness** — When modifying any register logic, consider the impact on timing paths
|
|
7
|
+
- **Consistent reset strategy** — Don't mix synchronous/asynchronous reset in the same module without a clear reason
|
|
8
|
+
|
|
9
|
+
### Mandatory Checks Before Modification
|
|
10
|
+
- Confirm the fan-out of the signal being modified — Who is reading this signal?
|
|
11
|
+
- Confirm the clock domain — Is this a clock domain crossing (CDC)? Is a synchronizer needed?
|
|
12
|
+
- Confirm bit width — Do widths match? Are there implicit truncations or extensions?
|
|
13
|
+
- Confirm FSM states — When modifying a state machine, are all state transitions fully covered?
|
|
14
|
+
|
|
15
|
+
### Prohibited
|
|
16
|
+
- No latches in `always @(*)` unless explicitly intended with a comment
|
|
17
|
+
- No missing else / default branches in combinational logic
|
|
18
|
+
- No modifying interface signals (ports) without updating all instantiation sites
|
|
19
|
+
- No modifying critical path logic without understanding timing constraints
|
|
20
|
+
|
|
21
|
+
### Testbench Rules
|
|
22
|
+
- New features must have corresponding testbench cases
|
|
23
|
+
- After modifying RTL, run existing simulations before checking results
|
|
24
|
+
- Prefer assertions / checkers over visual waveform inspection
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "startup|resume|clear|compact",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh\""
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PreToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"matcher": "Edit|Write|MultiEdit",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/pre-edit-guard.sh\""
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"matcher": "Edit|Write|MultiEdit",
|
|
26
|
+
"hooks": [
|
|
27
|
+
{
|
|
28
|
+
"type": "command",
|
|
29
|
+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/streak-breaker.sh\""
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"matcher": "Edit|Write|MultiEdit|Bash|Agent",
|
|
35
|
+
"hooks": [
|
|
36
|
+
{
|
|
37
|
+
"type": "command",
|
|
38
|
+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/action-counter.sh\""
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"matcher": "ExitPlanMode",
|
|
44
|
+
"hooks": [
|
|
45
|
+
{
|
|
46
|
+
"type": "command",
|
|
47
|
+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/phase-gate.sh\""
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"PostToolUse": [
|
|
53
|
+
{
|
|
54
|
+
"matcher": "Bash",
|
|
55
|
+
"hooks": [
|
|
56
|
+
{
|
|
57
|
+
"type": "command",
|
|
58
|
+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/post-error-remind.sh\""
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"PostToolUseFailure": [
|
|
64
|
+
{
|
|
65
|
+
"matcher": "Bash",
|
|
66
|
+
"hooks": [
|
|
67
|
+
{
|
|
68
|
+
"type": "command",
|
|
69
|
+
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/post-error-remind.sh\""
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commit
|
|
3
|
+
description: Smart commit — run tests, update docs and memory, then commit to ensure knowledge is not lost
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Execute the smart commit flow. Core principle: **commit code and knowledge together**.
|
|
8
|
+
|
|
9
|
+
## 1. Run Tests
|
|
10
|
+
|
|
11
|
+
Check the test command in CLAUDE.md and execute it. If tests fail, stop the commit and report.
|
|
12
|
+
Skip this step for projects with no configured test command.
|
|
13
|
+
|
|
14
|
+
## 2. Update Knowledge Files
|
|
15
|
+
|
|
16
|
+
Check each in order (simple changes may skip):
|
|
17
|
+
|
|
18
|
+
**docs/progress.md** — Does this change constitute a milestone or significant progress? If so, append a record.
|
|
19
|
+
|
|
20
|
+
**docs/debug-log.md** — Are there debug sessions that need to be closed or updated?
|
|
21
|
+
|
|
22
|
+
**CLAUDE.md** — Are there new components, interfaces, known pitfalls, or architectural changes to sync?
|
|
23
|
+
|
|
24
|
+
**Auto Memory** — Are there cross-session lessons worth remembering? (bug patterns, API pitfalls, debugging tips)
|
|
25
|
+
Update memory files, keeping MEMORY.md under 200 lines.
|
|
26
|
+
|
|
27
|
+
## 3. Execute git commit
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
git status
|
|
31
|
+
git diff --staged && git diff
|
|
32
|
+
git log --oneline -5
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- Selectively `git add` (don't use `git add -A`)
|
|
36
|
+
- Include docs/ and CLAUDE.md changes in the commit if modified
|
|
37
|
+
- Don't commit .env, credentials, or other sensitive files
|
|
38
|
+
- Follow existing commit message style
|
|
39
|
+
- Don't push (unless user explicitly requests it)
|
|
40
|
+
- If pre-commit hook fails, fix the issue and create a new commit (don't --amend)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: evaluate
|
|
3
|
+
description: Objectively evaluate external review/advice against your actual codebase knowledge. Use when pasting suggestions from reviewers, consultants, or AI who lack project context.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You have deep context from investigating this codebase. The user is about to paste external advice from someone who may NOT have that context. Your job is to be an **honest bridge** — not a yes-man, not a contrarian.
|
|
7
|
+
|
|
8
|
+
## Instructions
|
|
9
|
+
|
|
10
|
+
For each suggestion or recommendation in the external input:
|
|
11
|
+
|
|
12
|
+
### 1. Understand the intent
|
|
13
|
+
|
|
14
|
+
What problem is this suggestion trying to solve? Separate the **goal** (often valid) from the **specific approach** (may not fit).
|
|
15
|
+
|
|
16
|
+
### 2. Check against reality
|
|
17
|
+
|
|
18
|
+
Use your actual codebase knowledge to verify:
|
|
19
|
+
- Does the thing they're describing actually exist / work the way they assume?
|
|
20
|
+
- Are there constraints they likely don't know about?
|
|
21
|
+
- Have we already tried or considered this?
|
|
22
|
+
- Does it conflict with decisions already made (and documented)?
|
|
23
|
+
|
|
24
|
+
### 3. Verdict per item
|
|
25
|
+
|
|
26
|
+
For each suggestion, give one of:
|
|
27
|
+
|
|
28
|
+
- **Accept** — Suggestion is sound and fits the codebase reality. State what action to take.
|
|
29
|
+
- **Accept with modification** — The goal is right but the approach needs adjustment. Explain what to change and why.
|
|
30
|
+
- **Reject** — Doesn't apply, is based on wrong assumptions, or conflicts with known constraints. Explain specifically why, citing what you know about the codebase.
|
|
31
|
+
- **Needs investigation** — You don't have enough context to judge. State what you'd need to check.
|
|
32
|
+
|
|
33
|
+
### 4. Output format
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
## Evaluation of [source description]
|
|
37
|
+
|
|
38
|
+
### [suggestion 1 summary]
|
|
39
|
+
Verdict: accept / accept with modification / reject / needs investigation
|
|
40
|
+
Reasoning: [cite specific codebase facts, not general opinions]
|
|
41
|
+
Action: [what to do, if accepted]
|
|
42
|
+
|
|
43
|
+
### [suggestion 2 summary]
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
## Summary
|
|
47
|
+
Accepted: N | Modified: N | Rejected: N | Needs investigation: N
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Rules
|
|
51
|
+
|
|
52
|
+
- **Be specific** — "This doesn't apply" is not enough. Say WHY, citing files/code/decisions you know about.
|
|
53
|
+
- **Separate intent from approach** — A reviewer can be right about the problem and wrong about the solution.
|
|
54
|
+
- **Don't reject based on effort** — "That's a lot of work" is not a valid reason to reject. Only reject on technical grounds.
|
|
55
|
+
- **Don't accept out of deference** — External reviewer ≠ automatically correct. Your codebase context is the advantage here.
|
|
56
|
+
- **Flag your own uncertainty** — If you're not sure about something, say "needs investigation", don't guess.
|
|
57
|
+
- **Preserve the user's judgment** — You evaluate, the user decides. Present evidence, not directives.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: self-check
|
|
3
|
+
description: Periodic self-check — detect drift, mole-whacking, and discipline violations. Use with /loop for continuous monitoring.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Pause and honestly answer every question below. Do NOT skip any. Do NOT rationalize.
|
|
8
|
+
|
|
9
|
+
## 1. Am I still on track?
|
|
10
|
+
|
|
11
|
+
- What was the user's original request?
|
|
12
|
+
- What am I doing right now?
|
|
13
|
+
- Is my current action directly serving that request, or have I drifted?
|
|
14
|
+
- If drifted: **stop, state what the original goal was, and ask the user if current direction is correct.**
|
|
15
|
+
|
|
16
|
+
## 2. Am I mole-whacking?
|
|
17
|
+
|
|
18
|
+
- Have I edited the same file more than twice?
|
|
19
|
+
- Did I fix something, then break something else, and now I'm fixing that?
|
|
20
|
+
- Am I adding workarounds (try/catch, if/else guards) instead of fixing root cause?
|
|
21
|
+
- Am I guessing-and-checking instead of understanding?
|
|
22
|
+
- If yes to any: **stop immediately. List all attempted fixes, look for the common root cause, report to user.**
|
|
23
|
+
|
|
24
|
+
## 3. Am I being honest?
|
|
25
|
+
|
|
26
|
+
- Have I claimed something is "verified" or "working" without actually running it?
|
|
27
|
+
- Have I marked anything ✅ without pasting the verification command and output?
|
|
28
|
+
- Have I marked something "done" when it actually depends on an external resource I haven't tested against?
|
|
29
|
+
- Have I blamed an external tool/library/PDK without ruling out my own mistakes first?
|
|
30
|
+
- Have I altered or paraphrased tool output instead of quoting verbatim?
|
|
31
|
+
- Is there anything I stated confidently but am actually unsure about?
|
|
32
|
+
- If yes to any: **correct it now. Label uncertain claims as "unverified" or "assumption". Downgrade false ✅ to ⚠️ with reason.**
|
|
33
|
+
|
|
34
|
+
## 4. Am I respecting scope?
|
|
35
|
+
|
|
36
|
+
- Am I making changes the user didn't ask for? (refactoring, "improving", adding features)
|
|
37
|
+
- Am I about to do something irreversible without asking?
|
|
38
|
+
- Am I skipping the debugging process (gather → hypothesize → verify → fix)?
|
|
39
|
+
- If yes to any: **stop. Do only what was asked.**
|
|
40
|
+
|
|
41
|
+
## 5. Is progress recorded?
|
|
42
|
+
|
|
43
|
+
- When was `docs/progress.md` last updated?
|
|
44
|
+
- Have I completed any milestones or made key decisions since the last update?
|
|
45
|
+
- If yes: **update docs/progress.md NOW** with current status, completed items, and next steps.
|
|
46
|
+
- This is critical for context survival across compacts and sessions.
|
|
47
|
+
|
|
48
|
+
## 6. Status report
|
|
49
|
+
|
|
50
|
+
After answering the above, output a brief status:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
SELF-CHECK [timestamp]
|
|
54
|
+
Task: [original user request]
|
|
55
|
+
Current action: [what I'm doing now]
|
|
56
|
+
On track: yes/no/drifted
|
|
57
|
+
Mole-whacking: yes/no
|
|
58
|
+
Progress recorded: yes/updated now/no
|
|
59
|
+
Issues found: [list, or "none"]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If any issues were found, stop working and report to the user before continuing.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# [PROJECT_NAME] — CLAUDE.md
|
|
2
|
+
|
|
3
|
+
> General discipline rules are auto-injected via `.claude/rules/`. This file is for project-specific information only.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Project Overview
|
|
8
|
+
|
|
9
|
+
- **Project name**: [PROJECT_NAME]
|
|
10
|
+
- **One-line description**: [TODO — what this project aims to achieve]
|
|
11
|
+
- **Tech stack**: [TODO]
|
|
12
|
+
- **Key constraints**: [TODO — e.g., performance requirements, compatibility, security]
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Project Structure
|
|
17
|
+
|
|
18
|
+
[TODO — describe directory structure and module responsibilities]
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
├── src/ ← [TODO]
|
|
22
|
+
├── tests/ ← [TODO]
|
|
23
|
+
├── docs/
|
|
24
|
+
│ ├── progress.md ← Progress and decision log (maintained by Claude, do not edit manually)
|
|
25
|
+
│ └── debug-log.md ← Debug session log (maintained by Claude)
|
|
26
|
+
└── .claude/
|
|
27
|
+
├── rules/ ← Auto-injected rules
|
|
28
|
+
├── hooks/ ← Enforced hooks
|
|
29
|
+
└── agents/ ← Reviewer & investigator subagents
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Common Commands
|
|
35
|
+
|
|
36
|
+
[TODO — build, test, lint, run commands]
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Build
|
|
40
|
+
# [TODO]
|
|
41
|
+
|
|
42
|
+
# Test
|
|
43
|
+
# [TODO]
|
|
44
|
+
|
|
45
|
+
# Lint / Type Check
|
|
46
|
+
# [TODO]
|
|
47
|
+
|
|
48
|
+
# Run / Simulate
|
|
49
|
+
# [TODO]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Code Style
|
|
55
|
+
|
|
56
|
+
[TODO — team conventions]
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Known Pitfalls
|
|
61
|
+
|
|
62
|
+
[TODO — project-specific gotchas, examples:]
|
|
63
|
+
- [e.g., Module X's interface looks like REST but is actually WebSocket]
|
|
64
|
+
- [e.g., Database migrations must be backwards-compatible]
|
|
65
|
+
- [e.g., Third-party library v2 API has breaking changes, we're pinned to v1]
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Compact Supplement
|
|
70
|
+
|
|
71
|
+
When compacting, in addition to general rules (preserve task objectives, progress, decisions), also preserve:
|
|
72
|
+
- [TODO — project-specific context that must be retained]
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Decision Log
|
|
77
|
+
|
|
78
|
+
| Date | Decision | Reason | Impact |
|
|
79
|
+
|------|----------|--------|--------|
|
|
80
|
+
| | | | |
|