cc-discipline 2.3.1 → 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 +8 -0
- package/templates/.claude/hooks/post-error-remind.sh +5 -0
- package/templates/.claude/hooks/session-start.sh +1 -0
- package/templates/.claude/rules/00-core-principles.md +2 -1
- 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,6 +19,14 @@ 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
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."}}
|
|
@@ -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)
|
|
@@ -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,7 +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
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.
|
|
@@ -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
|
|