cc-discipline 2.3.0 → 2.4.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/init.sh +1 -1
- package/package.json +1 -1
- package/templates/.claude/hooks/action-counter.sh +9 -1
- package/templates/.claude/hooks/post-error-remind.sh +6 -1
- package/templates/.claude/hooks/pre-edit-guard.sh +7 -0
- package/templates/.claude/hooks/session-start.sh +1 -0
- package/templates/.claude/rules/00-core-principles.md +3 -1
- package/templates/.claude/rules/01-debugging.md +12 -5
- package/templates/.claude/rules/03-context-mgmt.md +12 -0
- package/templates/.claude/rules/05-phase-discipline.md +9 -7
- package/templates/.claude/rules/07-integrity.md +11 -0
- package/templates/.claude/skills/think/SKILL.md +1 -0
package/init.sh
CHANGED
|
@@ -470,7 +470,7 @@ if [ "$INSTALL_MODE" = "fresh" ]; then
|
|
|
470
470
|
echo -e "Created files:"
|
|
471
471
|
echo -e " ${GREEN}CLAUDE.md${NC} ← Project rules (fill in [TODO] sections)"
|
|
472
472
|
echo -e " ${GREEN}.claude/rules/${NC} ← Auto-injected rules"
|
|
473
|
-
echo -e " ${GREEN}.claude/hooks/${NC} ←
|
|
473
|
+
echo -e " ${GREEN}.claude/hooks/${NC} ← 7 discipline hooks (edit guard, streak breaker, git guard, phase gate, action counter, error remind, session start)"
|
|
474
474
|
echo -e " ${GREEN}.claude/agents/${NC} ← Reviewer & investigator subagents"
|
|
475
475
|
echo -e " ${GREEN}.claude/skills/commit/${NC} ← /commit smart commit"
|
|
476
476
|
echo -e " ${GREEN}.claude/skills/self-check/${NC} ← /self-check periodic discipline check"
|
package/package.json
CHANGED
|
@@ -19,9 +19,17 @@ COUNT=$(cat "$COUNT_FILE" 2>/dev/null) || COUNT=0
|
|
|
19
19
|
COUNT=$((COUNT + 1))
|
|
20
20
|
echo "$COUNT" > "$COUNT_FILE"
|
|
21
21
|
|
|
22
|
+
# Early-action phase check: first 3 actions get a planning reminder
|
|
23
|
+
if [ "$COUNT" -le 3 ]; then
|
|
24
|
+
cat <<JSONEOF
|
|
25
|
+
{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"PHASE CHECK (action #${COUNT}): Before writing code: (1) Have you completed research/understanding? (2) Has the user approved an approach? If this is a non-trivial task and you haven't planned first, STOP and plan before implementing. Starting code without user approval is a phase violation."}}
|
|
26
|
+
JSONEOF
|
|
27
|
+
exit 0
|
|
28
|
+
fi
|
|
29
|
+
|
|
22
30
|
if [ $((COUNT % THRESHOLD)) -eq 0 ]; then
|
|
23
31
|
cat <<JSONEOF
|
|
24
|
-
{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"AUTO SELF-CHECK (#${COUNT} actions): Pause and verify: (1) Am I still serving the user's original request, or have I drifted? (2) Am I fixing the same thing repeatedly (mole-whacking)? (3) Have I claimed anything as 'verified' without actually running it? (4) Am I making changes the user didn't ask for? (5) Have I updated docs/progress.md with current status and completed milestones? If progress.md is stale, update it NOW before continuing. (6) Plan fidelity: if executing a plan, compare what the current step asked for vs what I actually delivered — am I cutting corners or simplifying the intent? Check the acceptance criteria. (7) Friction check: did any hook/rule get in the way or miss something since last check? If so, note it in one line for /retro later. If ANY answer is concerning, STOP and report to the user before continuing."}}
|
|
32
|
+
{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"AUTO SELF-CHECK (#${COUNT} actions): Pause and verify: (1) Am I still serving the user's original request, or have I drifted? (2) Am I fixing the same thing repeatedly (mole-whacking)? (3) Have I claimed anything as 'verified' without actually running it? (4) Am I making changes the user didn't ask for? (5) Have I updated docs/progress.md with current status and completed milestones? If progress.md is stale, update it NOW before continuing. (6) Plan fidelity: if executing a plan, compare what the current step asked for vs what I actually delivered — am I cutting corners or simplifying the intent? Check the acceptance criteria. (7) Quality check: am I lowering quality to avoid difficulty? If I'm about to skip a verification, simplify an approach, or take a shortcut — STOP and ask the user instead of silently pushing forward. (8) Friction check: did any hook/rule get in the way or miss something since last check? If so, note it in one line for /retro later. If ANY answer is concerning, STOP and report to the user before continuing."}}
|
|
25
33
|
JSONEOF
|
|
26
34
|
fi
|
|
27
35
|
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
# post-error-remind.sh — PostToolUse / PostToolUseFailure hook
|
|
3
3
|
# Detects error patterns in Bash output and reminds Claude to follow debugging discipline
|
|
4
4
|
#
|
|
5
|
+
# NOTE: We use exit 2 intentionally for Post hooks.
|
|
6
|
+
# exit 0 is completely silent — no way to inject text from Post hooks.
|
|
7
|
+
# exit 2 + stderr is the ONLY mechanism to show reminders to Claude after tool execution.
|
|
8
|
+
# The tool has already executed — exit 2 doesn't block execution, it injects the message.
|
|
9
|
+
#
|
|
5
10
|
# Design principles:
|
|
6
11
|
# - Only match REAL error patterns, not the word "error" in any context
|
|
7
12
|
# - Skip non-Bash tools (Edit/Write/Read have their own error handling)
|
|
@@ -92,7 +97,7 @@ fi
|
|
|
92
97
|
# --- Emit reminder if error detected ---
|
|
93
98
|
|
|
94
99
|
if [ "$HAS_ERROR" = true ]; then
|
|
95
|
-
REMINDER="ERROR DETECTED. Follow debugging discipline: 1. Do NOT modify code immediately 2. Fully understand the error message 3. List possible causes
|
|
100
|
+
REMINDER="ERROR DETECTED. Follow debugging discipline: 1. Do NOT modify code immediately 2. Fully understand the error message 3. List >=3 possible causes — label them HYPOTHESES, not root cause 4. Record in docs/debug-log.md 5. Eliminate >=2 hypotheses with evidence BEFORE declaring root cause 6. Only then fix. WARNING: Do NOT say 'found the root cause' or 'the issue is' after seeing one error — that kills investigation. Say 'possible cause' until you have elimination evidence."
|
|
96
101
|
|
|
97
102
|
if [ "$ERROR_TYPE" = "test" ]; then
|
|
98
103
|
REMINDER="$REMINDER. WARNING: Test failure — do NOT change the test to make it pass! First determine if it's a code bug or an outdated test."
|
|
@@ -76,4 +76,11 @@ if [ "$HAS_JQ" = true ]; then
|
|
|
76
76
|
fi
|
|
77
77
|
fi
|
|
78
78
|
|
|
79
|
+
# ─── Bug-fix sanity check ───
|
|
80
|
+
# Inject a lightweight reminder on source file edits:
|
|
81
|
+
# "If this is a bug fix, have you eliminated alternative hypotheses?"
|
|
82
|
+
# Uses additionalContext (non-blocking) so it doesn't slow down normal edits.
|
|
83
|
+
cat <<JSONEOF
|
|
84
|
+
{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"If this edit is a bug fix: have you listed >=3 possible causes and eliminated >=2 with evidence? If not, you are guessing, not debugging. Say 'possible cause', not 'root cause', until you have elimination evidence."}}
|
|
85
|
+
JSONEOF
|
|
79
86
|
exit 0
|
|
@@ -38,6 +38,7 @@ Reminders:
|
|
|
38
38
|
- Before editing: root cause identified? scope respected? change recorded?
|
|
39
39
|
- 3 consecutive failures → stop and report to user
|
|
40
40
|
- Do NOT jump to implementation before user confirms the approach
|
|
41
|
+
- Do NOT assume project state (phase, status, dependencies) — verify by reading files or asking
|
|
41
42
|
EOF
|
|
42
43
|
|
|
43
44
|
exit 0
|
|
@@ -7,6 +7,8 @@ description: "Core working principles — auto-injected before all operations"
|
|
|
7
7
|
|
|
8
8
|
1. **Understand before acting** — Before modifying any file, state: what you're changing, why, and the expected impact
|
|
9
9
|
2. **Don't lock onto the first explanation** — After finding a suspected cause, list >=2 alternative hypotheses before acting
|
|
10
|
-
3. **Minimal change
|
|
10
|
+
3. **Minimal change, minimal complexity** — No large-scale refactors unless explicitly requested. When proposing solutions, prefer the simplest approach that meets requirements. If a lightweight solution exists, do NOT propose a heavyweight one unless the user asks for it.
|
|
11
11
|
4. **3 consecutive failures → forced stop** — Report current state, attempted solutions, and points of confusion; wait for human guidance
|
|
12
12
|
5. **Distinguish trigger from root cause** — The first anomaly you see is often just the trigger, not the root cause
|
|
13
|
+
6. **"Root cause" is a conclusion, not a guess** — You may NOT use the phrase "root cause" or "found the issue" unless you have: (a) listed ≥3 hypotheses, (b) eliminated ≥2 with evidence, (c) have direct proof for the remaining one. Until then, say "possible cause" or "hypothesis". Premature certainty kills investigation.
|
|
14
|
+
7. **Follow established procedures** — When a project has a Makefile, CI script, setup.sh, or documented install process, follow it exactly. Do NOT invent shortcuts or install dependencies individually. Read the build/install instructions first. If none exist, ask.
|
|
@@ -9,14 +9,21 @@
|
|
|
9
9
|
- List >=3 possible causes
|
|
10
10
|
- Annotate each with supporting/contradicting evidence
|
|
11
11
|
- Record hypotheses in `docs/debug-log.md`
|
|
12
|
+
- **Do NOT declare any single hypothesis as "the root cause" at this stage**
|
|
12
13
|
|
|
13
|
-
### Phase 3: Verify
|
|
14
|
-
-
|
|
14
|
+
### Phase 3: Verify (do NOT jump to fixing)
|
|
15
|
+
- Design a minimal experiment to confirm/refute EACH hypothesis
|
|
16
|
+
- Run the experiment and record results
|
|
17
|
+
- Eliminate hypotheses one by one with evidence
|
|
15
18
|
- Update debug-log as each hypothesis is eliminated
|
|
19
|
+
- **Only after ≥2 hypotheses are eliminated with evidence may you identify a root cause**
|
|
16
20
|
|
|
17
21
|
### Phase 4: Fix
|
|
18
|
-
-
|
|
19
|
-
- Explain how the fix addresses the root cause (not just the symptoms)
|
|
22
|
+
- State which hypotheses were eliminated and how
|
|
23
|
+
- Explain how the fix addresses the confirmed root cause (not just the symptoms)
|
|
20
24
|
- Run all related tests after fixing
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
### Absolutely forbidden
|
|
27
|
+
- Seeing an error and immediately changing code to "try something"
|
|
28
|
+
- Declaring "root cause" after seeing a single error message — that's a hypothesis, not a conclusion
|
|
29
|
+
- Stopping investigation after the first plausible explanation — plausible ≠ confirmed
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
- Ensure progress.md is up to date before compact
|
|
15
15
|
- First thing after compact: read `docs/progress.md` to restore context
|
|
16
16
|
|
|
17
|
+
### When tasks feel overwhelming
|
|
18
|
+
Hard tasks create discomfort — the urge to simplify, declare partial success, or find an exit. This is normal. But the wrong response is to lower quality or invent excuses. Here's how to stay grounded:
|
|
19
|
+
|
|
20
|
+
- **It's OK to be stuck.** Say "I'm stuck on X because Y" — that's honest, and the user can help. What's NOT OK is hiding behind "context is full" or "let's continue in a new session" — these are avoidance, not solutions.
|
|
21
|
+
- **Shrink the problem.** When the whole task feels too big, stop looking at the whole. What is the ONE next thing you can verify? Do that. Then the next. Small verified steps compound into completed tasks.
|
|
22
|
+
- **Uncertainty is normal for hard problems.** You don't need to know the full answer to make progress. Verify what you can, label what you can't, and keep moving.
|
|
23
|
+
- **Progress = what you've verified, not how much code you've written.** Three lines with a passing test is more progress than 200 lines of unverified code.
|
|
24
|
+
- **When in doubt, stop and ask — this is mandatory, not optional.** If you notice yourself about to take a shortcut, simplify an approach, or skip a verification step, that is your signal to STOP and check in with the user. Say: "I'm about to [shortcut], because [reason]. Should I proceed this way, or do you want me to [full-quality alternative]?" Silently lowering quality and pushing forward is the worst outcome — it wastes both your work and the user's time, and the further you go the harder it is to undo.
|
|
25
|
+
- **Remember why you're here.** Easy tasks don't need you — the user can do those alone. They brought you in precisely because the task is hard. Difficulty is not a signal to retreat; it's where you provide the most value. Pushing through the hard parts with care and persistence is what makes the collaboration worthwhile.
|
|
26
|
+
|
|
17
27
|
### Prohibited
|
|
18
28
|
- Do not start a large new task when context is nearly full
|
|
19
29
|
- Do not mix unrelated tasks in a single conversation
|
|
30
|
+
- Do not use context pressure as a reason to skip edge cases, simplify solutions, or omit verification
|
|
31
|
+
- Do not propose "continuing in a new session" as a way to avoid completing difficult work
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
## Phase Discipline
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Every task progresses through phases. Do NOT skip or jump ahead.
|
|
4
4
|
|
|
5
5
|
### Phases
|
|
6
|
-
- **Research**: read only
|
|
7
|
-
- **Plan**: discuss approach, write plan
|
|
8
|
-
- **Implement**: execute the agreed plan
|
|
6
|
+
- **Research**: read only. No edits, no plans. Output: findings and questions.
|
|
7
|
+
- **Plan**: discuss approach, propose options, write plan. No code edits.
|
|
8
|
+
- **Implement**: execute the agreed plan. Code changes allowed.
|
|
9
9
|
|
|
10
10
|
### Rules
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
1. If the user declares a phase, stay in it until they say otherwise.
|
|
12
|
+
2. If the current phase is unclear, ask before proceeding.
|
|
13
|
+
3. **Transitioning from Research/Plan → Implement requires explicit user approval.** Words like "go ahead", "do it", "approved", "yes" count. Your own "I'll go ahead and..." does NOT count.
|
|
14
|
+
4. If you are about to write code while still in Research or Plan — that is a phase violation. Stop and ask.
|
|
15
|
+
5. Starting a non-trivial task without planning (or /think) is a phase skip. Default sequence: understand → plan → get approval → implement.
|
|
@@ -43,6 +43,17 @@ Before starting work, identify and verify:
|
|
|
43
43
|
|
|
44
44
|
**Rule: List key assumptions at the start. Verify each one. Record how it was verified.**
|
|
45
45
|
|
|
46
|
+
### 4a. Project state is NEVER assumed
|
|
47
|
+
|
|
48
|
+
Project phases (frozen, submitted, taped-out, deployed, released), component statuses (working, broken, deprecated), and environment state (installed, configured, running) must be verified by reading actual files (status docs, CI output, lock files) or asking the user.
|
|
49
|
+
|
|
50
|
+
Prohibited inferences:
|
|
51
|
+
- "Since we already submitted X..." — did we? Check.
|
|
52
|
+
- "The design is frozen, so..." — is it? Read the status doc.
|
|
53
|
+
- "Dependencies are installed..." — are they? Run the check command.
|
|
54
|
+
|
|
55
|
+
**Rule: When about to act on a project state assumption, STOP. Read the file that proves the state, or ask the user. "I assume X is in state Y" is not acceptable.**
|
|
56
|
+
|
|
46
57
|
### 5. External communications require human review
|
|
47
58
|
|
|
48
59
|
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.
|
|
@@ -70,6 +70,7 @@ Rules:
|
|
|
70
70
|
- Follow existing codebase patterns unless there's a strong reason not to
|
|
71
71
|
- Flag risks or unknowns you've spotted
|
|
72
72
|
- **Every step must have acceptance criteria** — "done when" must be observable and verifiable, not vague. Bad: "done when refactored". Good: "done when 3 methods extracted, each ≤20 lines, all tests pass"
|
|
73
|
+
- **Simplicity bias** — If a simple approach meets all requirements, list it first and recommend it. Do NOT lead with complex/elegant solutions unless the user signals they want that. "Simple but sufficient" beats "powerful but overkill".
|
|
73
74
|
|
|
74
75
|
## Step 4: Self-review
|
|
75
76
|
|