@yeison.restrepo.r/code-conductor 1.23.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.
Files changed (43) hide show
  1. package/LICENSE +185 -0
  2. package/README.md +314 -0
  3. package/bin/code-conductor.mjs +133 -0
  4. package/global/CLAUDE.md +93 -0
  5. package/global/commands/cc-checkpoint.md +50 -0
  6. package/global/commands/cc-compact.md +49 -0
  7. package/global/commands/cc-lang.md +32 -0
  8. package/global/commands/cc-stack.md +69 -0
  9. package/global/hooks/graphify-ast-refresh.py +81 -0
  10. package/global/hooks/verbosity-remind.sh +372 -0
  11. package/global/memory/personal.md +24 -0
  12. package/global/memory/verbosity.md +7 -0
  13. package/global/settings.json +24 -0
  14. package/lib/installer/config.mjs +51 -0
  15. package/lib/installer/deploy.mjs +76 -0
  16. package/lib/installer/env.mjs +35 -0
  17. package/lib/installer/settings.mjs +77 -0
  18. package/package.json +34 -0
  19. package/project-template/.claude/commands/cc-debug.md +42 -0
  20. package/project-template/.claude/commands/cc-docs.md +49 -0
  21. package/project-template/.claude/commands/cc-implement.md +164 -0
  22. package/project-template/.claude/commands/cc-init.md +84 -0
  23. package/project-template/.claude/commands/cc-plan.md +114 -0
  24. package/project-template/.claude/commands/cc-refactor.md +42 -0
  25. package/project-template/.claude/commands/cc-resume.md +142 -0
  26. package/project-template/.claude/commands/cc-review.md +77 -0
  27. package/project-template/.claude/commands/cc-spec.md +138 -0
  28. package/project-template/.claude/commands/cc-test.md +56 -0
  29. package/project-template/.claude/hooks/context-guard.ps1 +55 -0
  30. package/project-template/.claude/hooks/context-guard.sh +43 -0
  31. package/project-template/.claude/hooks/post-compact.ps1 +41 -0
  32. package/project-template/.claude/hooks/post-compact.sh +36 -0
  33. package/project-template/.claude/hooks/pre-tool-use.sh +81 -0
  34. package/project-template/.claude/hooks/verbosity-remind.sh +168 -0
  35. package/project-template/.claude/memory/context-threshold.txt +1 -0
  36. package/project-template/.claude/memory/project.md +48 -0
  37. package/project-template/.claude/settings.json +52 -0
  38. package/project-template/CLAUDE.md +104 -0
  39. package/skills/agent-delegation.md +44 -0
  40. package/skills/code-simplifier.md +124 -0
  41. package/skills/critical-review.md +75 -0
  42. package/skills/memory-first.md +50 -0
  43. package/skills/verbosity.md +30 -0
@@ -0,0 +1,77 @@
1
+ import { readFileSync, writeFileSync, copyFileSync, existsSync, readdirSync, unlinkSync } from 'node:fs';
2
+ import { join, dirname, basename } from 'node:path';
3
+
4
+ const FINGERPRINT = 'verbosity-remind.sh';
5
+ const MAX_MALFORMED_BACKUPS = 5;
6
+
7
+ function utcStamp(d) {
8
+ // Date.toISOString() is ALWAYS UTC (trailing Z). Strip the separators and the
9
+ // fractional millis: 2026-07-05T12:34:56.789Z -> 20260705T123456Z. Fixed width,
10
+ // so lexical filename order == chronological order (drives pruneMalformedBackups).
11
+ return d.toISOString().replace(/[-:]/g, '').replace(/\.\d+Z$/, 'Z');
12
+ }
13
+
14
+ export function verbosityHookCommand(home) {
15
+ // Normalize backslashes to forward slashes: the command is executed by `bash`
16
+ // (Git Bash/WSL on Windows), which treats `\` as an escape char, so a native
17
+ // Windows path would break. Forward slashes are valid on every platform and keep
18
+ // the stored command byte-stable, which is what the idempotency check compares.
19
+ const hookPath = join(home, '.claude', 'hooks', 'verbosity-remind.sh').replace(/\\/g, '/');
20
+ return `bash ${hookPath}`;
21
+ }
22
+
23
+ function entryHasCommand(entry, predicate) {
24
+ return entry && Array.isArray(entry.hooks) && entry.hooks.some(h => h && predicate(h));
25
+ }
26
+
27
+ function backupMalformed(settingsPath, now) {
28
+ const dst = `${settingsPath}.malformed-backup.${utcStamp(now)}`;
29
+ copyFileSync(settingsPath, dst);
30
+ pruneMalformedBackups(settingsPath);
31
+ }
32
+
33
+ export function pruneMalformedBackups(settingsPath, keep = MAX_MALFORMED_BACKUPS) {
34
+ const dir = dirname(settingsPath);
35
+ const prefix = `${basename(settingsPath)}.malformed-backup.`;
36
+ const backups = readdirSync(dir).filter(n => n.startsWith(prefix)).sort();
37
+ for (const n of backups.slice(0, Math.max(0, backups.length - keep))) {
38
+ try { unlinkSync(join(dir, n)); } catch { /* best effort */ }
39
+ }
40
+ }
41
+
42
+ export function mergeVerbosityHook(settingsPath, hookCmd, now = new Date()) {
43
+ // A missing settings.json (ENOENT) is not an error: initialize a fresh, empty
44
+ // config object and let the merge create the file. The existsSync check plus
45
+ // the ENOENT catch guard against both the plain-missing case and a TOCTOU
46
+ // delete between the check and the read.
47
+ let raw = '{}';
48
+ if (existsSync(settingsPath)) {
49
+ try { raw = readFileSync(settingsPath, 'utf8'); }
50
+ catch (e) { if (e.code !== 'ENOENT') throw e; }
51
+ }
52
+ // A zero-byte or whitespace-only file is NOT malformed — it is an uninitialized
53
+ // config. Treat it as an empty object and merge (matching install.sh, which starts
54
+ // from {} on an empty file). Only genuine non-empty invalid JSON triggers a backup.
55
+ if (raw.trim() === '') raw = '{}';
56
+ let obj;
57
+ try { obj = JSON.parse(raw); } catch { backupMalformed(settingsPath, now); return { status: 'malformed-skipped' }; }
58
+ if (obj === null || typeof obj !== 'object' || Array.isArray(obj)) {
59
+ backupMalformed(settingsPath, now);
60
+ return { status: 'malformed-skipped' };
61
+ }
62
+ if (typeof obj.hooks !== 'object' || obj.hooks === null || Array.isArray(obj.hooks)) obj.hooks = {};
63
+ let arr = Array.isArray(obj.hooks.UserPromptSubmit) ? obj.hooks.UserPromptSubmit : [];
64
+
65
+ if (arr.some(e => entryHasCommand(e, h => h.command === hookCmd))) return { status: 'idempotent-skip' };
66
+
67
+ arr = arr.filter(e => !entryHasCommand(e, h => typeof h.command === 'string' && h.command.includes(FINGERPRINT)));
68
+ arr.push({ matcher: '', hooks: [{ type: 'command', command: hookCmd }] });
69
+ obj.hooks.UserPromptSubmit = arr;
70
+ // Enforce 2-space indentation (matches install.sh's JSON.stringify(d,null,2) and the
71
+ // bundled settings.json) rather than detecting/preserving the user's indent width —
72
+ // one canonical format keeps diffs stable and the merge deterministic. The `+ '\n'`
73
+ // appends the single trailing newline POSIX text files expect (and that the bundled
74
+ // settings.json already ends with). Explicit utf8 encoding.
75
+ writeFileSync(settingsPath, JSON.stringify(obj, null, 2) + '\n', 'utf8');
76
+ return { status: 'merged' };
77
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@yeison.restrepo.r/code-conductor",
3
+ "version": "1.23.0",
4
+ "description": "A spec-first, token-efficient Claude Code configuration and installer CLI.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/yeisonrestrepo/code-conductor.git"
8
+ },
9
+ "type": "module",
10
+ "bin": {
11
+ "code-conductor": "bin/code-conductor.mjs"
12
+ },
13
+ "files": [
14
+ "bin/",
15
+ "lib/",
16
+ "global/",
17
+ "skills/",
18
+ "project-template/"
19
+ ],
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "test": "vitest run",
28
+ "coverage": "vitest run --coverage"
29
+ },
30
+ "devDependencies": {
31
+ "@vitest/coverage-v8": "^3.0.0",
32
+ "vitest": "^3.0.0"
33
+ }
34
+ }
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: "(Conductor) Systematically diagnose and fix a bug"
3
+ ---
4
+
5
+ ## Phase 0 — Skill activation
6
+
7
+ Before doing anything else, invoke both skills in order:
8
+
9
+ ```
10
+ Skill({ skill: "subagent-driven-development", args: "$ARGUMENTS" })
11
+ Skill({ skill: "critical-review" })
12
+ ```
13
+
14
+ `subagent-driven-development` delegates investigation to sub-agents (graph query + git log — no inline file reads). `critical-review` Phase 2 RESILIENCE check then runs on the proposed fix before it is applied — confirm the fix doesn't introduce a silent failure or new boundary condition. The fix must pass Phase 3 self-correction before being committed. End with `[VALIDATION]`.
15
+
16
+ ---
17
+
18
+ Characterize the problem before investigating:
19
+
20
+ **Symptom:** [what is observed]
21
+ **Expected:** [what should happen]
22
+ **Reproduction:** [exact steps to reproduce]
23
+ **Frequency:** [always / intermittent / only under condition X]
24
+ **Context:** [environment, recent changes, logs]
25
+
26
+ List 2–4 hypotheses ordered by probability. Present them and confirm which to investigate first before touching any code.
27
+
28
+ For visual bugs or UI flow problems, activate Playwright MCP:
29
+ "This looks like a visual/UI issue. I'll use Playwright MCP to inspect it — confirm?"
30
+
31
+ **Investigation:**
32
+ - Use grep to locate relevant code — never read whole files
33
+ - Read only the sections that match the hypothesis
34
+ - Check git log for recent changes to the area
35
+
36
+ **Report:**
37
+ - Root cause: [file:line]
38
+ - Why it happens: [explanation]
39
+ - Impact: [what else could be affected]
40
+ - Proposed fix: [exact change]
41
+
42
+ Apply the fix only after the developer confirms. After fixing, suggest a test that would have caught this bug.
@@ -0,0 +1,49 @@
1
+ ---
2
+ description: "(Conductor) Audit and update project documentation"
3
+ ---
4
+
5
+ Audit existing docs first:
6
+ - Run: `grep -r "TODO\|FIXME\|@deprecated" src/ --include="*.{ts,js,py,java,go,rs}" -l`
7
+ - Check if public functions and classes already have doc comments
8
+ - Identify the highest-impact gaps (public API, core modules)
9
+
10
+ **Inline doc format by language:**
11
+
12
+ TypeScript/JavaScript — JSDoc:
13
+ ```typescript
14
+ /**
15
+ * Finds a user by their unique identifier.
16
+ * Returns null when no matching user exists — callers must handle this case.
17
+ */
18
+ function getUserById(id: string): User | null { ... }
19
+ ```
20
+
21
+ Python — docstrings:
22
+ ```python
23
+ def get_user_by_id(user_id: str) -> User | None:
24
+ """
25
+ Find a user by their unique identifier.
26
+
27
+ Returns None when no matching user exists — callers must handle this case.
28
+ """
29
+ ```
30
+
31
+ Java — JavaDoc:
32
+ ```java
33
+ /**
34
+ * Finds a user by their unique identifier.
35
+ * Returns {@code Optional.empty()} when no matching user exists.
36
+ */
37
+ Optional<User> getUserById(String id);
38
+ ```
39
+
40
+ Go — GoDoc:
41
+ ```go
42
+ // GetUserByID returns the user with the given ID.
43
+ // Returns ErrNotFound if no matching user exists.
44
+ func GetUserByID(ctx context.Context, id string) (User, error) { ... }
45
+ ```
46
+
47
+ **Rule:** Document WHY (non-obvious behavior, side effects, callers' responsibilities), not WHAT (the function name already says that).
48
+
49
+ Preview all doc changes before writing to files. Show a diff of what will be added.
@@ -0,0 +1,164 @@
1
+ ---
2
+ description: "(Conductor) Execute implementation tasks from an approved plan"
3
+ ---
4
+
5
+ ## Phase entry - Resume Read
6
+
7
+ Before doing anything else, restore any stored context for the current commit by running `scripts/resume-read.mjs`. It resolves the current git hash, prefers a valid DB snapshot (`conductor-db get-snapshot`), falls back to the `.claude/memory/session-snapshot.json` handoff file, and prints a `RESUME_HIT` block on a hit / nothing on a miss. Capture its stdout **and** its exit code with the canonical per-platform form (each first probes for `node` and treats its absence as a clean miss, never an error):
8
+
9
+ - **Unix / Git Bash:**
10
+ ```sh
11
+ if command -v node >/dev/null 2>&1; then
12
+ resume_out="$(node scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
13
+ else resume_rc=3; resume_out=""; fi
14
+ ```
15
+ - **PowerShell:**
16
+ ```powershell
17
+ if (Get-Command node -ErrorAction SilentlyContinue) {
18
+ $__eap = $ErrorActionPreference; $ErrorActionPreference = 'Continue'
19
+ if (Test-Path variable:PSNativeCommandUseErrorActionPreference) {
20
+ $__nap = $PSNativeCommandUseErrorActionPreference; $PSNativeCommandUseErrorActionPreference = $false
21
+ }
22
+ try {
23
+ $resume_out = node scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
24
+ } catch { $resume_rc = 3; $resume_out = "" }
25
+ finally {
26
+ $ErrorActionPreference = $__eap
27
+ if (Test-Path variable:__nap) { $PSNativeCommandUseErrorActionPreference = $__nap }
28
+ }
29
+ } else { $resume_rc = 3; $resume_out = "" }
30
+ ```
31
+
32
+ Branch on `resume_rc` - **only `0` and `4` are meaningful; every other code proceeds fresh:**
33
+
34
+ - **`0`** → parse the captured block and adopt it as this phase's starting context, then echo one banner to the user: `> Resumed from stored snapshot @ <commit> (phase: <phase>)`, appending ` (checkpoint prose available)` when the block reports `prose: available`. Parsing (the command owns normalization): split on `\n`; strip a trailing `\r` from every line; drop leading/trailing wholly-blank lines; require `lines[0].trim() === 'RESUME_HIT'` (anything else = miss); `key: value` lines split on the first `': '` (both sides trimmed); the `pending:` block is every subsequent `^\s*-\s+` line up to the first blank line or EOF, each item trimmed. Unknown keys are ignored. In PowerShell, `node …` binds `string[]` for multi-line output - normalize with `$lines = @($resume_out)`; a `$null`/empty capture with `resume_rc = 3` is a miss.
35
+ - **`4`** → **operational halt.** Do not run this phase's normal work. Emit exactly: `SNAP_INVALID: corrupt handoff at .claude/memory/session-snapshot.json - inspect or remove it, then re-run.` and enter standby awaiting user action. The corrupt file is left on disk (the script did not delete it).
36
+ - **`3` or any other code** → **proceed fresh** (clean miss, bypass, degrade, absent `node`, or any unexpected runtime code). Ignore the capture.
37
+
38
+ `resume-read.mjs` writes its own trace lines to `.conductor/last-write.log` via `appendFileSync`; the `2>>` redirect above only sinks the incidental exit-4 halt reason away from the UI - it is not the trace channel.
39
+
40
+ ---
41
+
42
+ Read `.claude/memory/project.md` before starting any task.
43
+
44
+ ## Surgical Plan State Ritual
45
+
46
+ Execute all plan tasks using the 5-step surgical ritual below. **Do not read the full plan file.**
47
+
48
+ ### Checkbox State Protocol
49
+
50
+ | Symbol | Meaning |
51
+ |--------|---------|
52
+ | `[ ]` | Pending |
53
+ | `[>]` | In-progress (pre-flipped before execution begins) |
54
+ | `[X]` | Complete |
55
+ | `[!]` | Failed; halt immediately |
56
+
57
+ The Grep locator targets only `[ ]` states. `[>]`, `[X]`, and `[!]` are invisible to the locator.
58
+
59
+ ### String Rules
60
+
61
+ **Comparison normalization** (Steps 2 and 3 — used only to decide if strings match, never as `old_string`):
62
+ 1. Strip leading/trailing ASCII whitespace (space, tab)
63
+ 2. Strip `\r`
64
+ 3. Strip Unicode invisible characters: `​`, ``, `‌`, `‍`
65
+
66
+ **`old_string` construction** (Steps 3 and 5 — the actual string passed to `Edit`):
67
+ - Take the Read result verbatim; strip trailing whitespace and `\r` only
68
+ - Preserve all leading whitespace (indentation)
69
+ - Do NOT strip Unicode invisibles
70
+
71
+ ### Step 1: Locate
72
+
73
+ Run `Grep` with:
74
+ - `pattern`: `\[ \] \[T-\d{3,}(-[A-Z0-9]+)*\]`
75
+ - `path`: active plan file path (resolved from session context; never the workspace root)
76
+ - `head_limit: 20`
77
+ - `offset`: total results examined so far in this scan loop (starts at 0)
78
+
79
+ **Fallback**: if `offset` is unsupported, replace the loop with a single `head_limit: 200` Grep.
80
+
81
+ **Unicode note**: the pattern assumes clean ASCII `[ ]` (U+0020 space only between brackets). Task lines with Unicode invisible characters within the checkbox brackets will not be matched; this condition is prevented by the ASCII-only generation rule in `cc-plan.md` (Task 3).
82
+
83
+ From the returned batch, apply dependency evaluation:
84
+ - **Eligible**: all declared prerequisites carry `[X]`
85
+ - **Transiently blocked** (`[ ]` prerequisite): skip; advance offset and re-run Grep
86
+ - **Stalled** (`[>]` prerequisite): halt with `PREREQUISITE_IN_PROGRESS`; report the in-progress task ID; do not skip to unrelated tasks
87
+ - **Permanently blocked** (`[!]` prerequisite): halt with `DEPENDENCY_FAILED`; report the failed prerequisite ID
88
+
89
+ **Scan loop cap**: 10 Grep iterations maximum (<=200 tasks). If the cap is reached with no eligible task, halt with `SCAN_LIMIT_EXCEEDED`; list all blocked tasks and their unmet dependencies.
90
+
91
+ If Grep returns no `[ ]` matches and `offset = 0`: output a completion summary and stop. If Grep returns no `[ ]` matches and `offset > 0`: halt with `SCAN_LIMIT_EXCEEDED`; all pending tasks are blocked (do not output a completion summary).
92
+
93
+ ### Step 2: Verify
94
+
95
+ `Read` the active plan file with `offset: N-1, limit: 1` (N = 1-based line number from Step 1).
96
+
97
+ Apply Comparison Normalization to both the Read result and the Grep match:
98
+ - Normalized match → proceed to Step 3 using the Read result for `old_string` construction
99
+ - Normalized mismatch → line drift; discard N and return to Step 1
100
+
101
+ **Drift cap**: after 5 consecutive drift mismatches, halt with `VERIFY_DRIFT_EXCEEDED`.
102
+
103
+ ### Step 3: Pre-flip
104
+
105
+ Assert uniqueness: run `Grep` for the exact task ID — for task `[T-001-A]`, use pattern `\[T-001-A\]` (the closing `\]` prevents sub-task prefix matches without requiring PCRE2). Scope to the active plan file. Confirm match count = 1. If count ≠ 1, halt and report the ID for manual resolution.
106
+
107
+ Construct `old_string` using the `old_string` construction rule. Use `Edit` to replace `[ ]` with `[>]`.
108
+
109
+ **Pre-flip retry cap**: if `Edit` reports `old_string` not found, return to Step 1. After 3 consecutive failures on the same task ID: run `Grep` for the task ID pattern scoped to the active plan file → `Read` the matched line (`offset: N-1, limit: 1`) → construct `old_string` from the Read result verbatim (trailing whitespace and `\r` stripped, regardless of current checkbox state) → construct `new_string` by replacing only the **first** `[_]` pattern (where `_` is any single character) with `[!]`, preserving all other brackets in the line → apply `Edit`. Then halt with a pre-flip failure report.
110
+
111
+ ### Step 4: Execute
112
+
113
+ Carry out the task described on that line.
114
+
115
+ ### Step 5: Post-flip
116
+
117
+ Construct `old_string` from the pre-flip line with `[ ]` replaced by `[>]` (the state after Step 3). Apply the `old_string` construction rule. Use `Edit` to replace:
118
+ - `[>]` → `[X]` on success
119
+ - `[>]` → `[!]` on failure
120
+
121
+ On `[!]`: proceed to Step 6 to record the failure state, then halt with a failure report. Post-flip Edit no-match (unexpected `[>]` absence) → halt immediately for manual resolution; do not proceed to Step 6.
122
+
123
+ ### Step 6: Hook
124
+
125
+ Runs after both success (`[X]`) and failure (`[!]`) paths. Record the task's final state to the local cache, best-effort:
126
+
127
+ 1. Probe `node --version`. If it is missing or below `22.5.0`, skip the cache write (the `node:sqlite` engine needs `>= 22.5`); the plan file remains authoritative.
128
+ 2. Decide how to launch so that an unrecognized flag can never fatally abort Node at startup. Probe with throwaway children, in order:
129
+ a. **No flag first:** run `node --no-warnings -e "require('node:sqlite')"`. Exit 0 means `node:sqlite` is stable on this Node — launch the recorder **without** `--experimental-sqlite`.
130
+ b. **Flag second:** else run `node --experimental-sqlite --no-warnings -e "require('node:sqlite')"`. Exit 0 means the flag is needed and recognized — launch the recorder **with** `--experimental-sqlite --no-warnings`.
131
+ c. **Neither:** else skip the cache write. Both a too-old Node and a future Node that removed/renamed the flag land here.
132
+
133
+ Each probe is a disposable child; a non-zero exit — including a fatal `bad option: --experimental-sqlite` from a Node that does not recognize the flag — is caught and simply advances to the next branch. The fatal startup error is therefore always contained inside a probe whose failure is expected; it never propagates and never aborts the hook.
134
+ 3. Launch the chosen form, from the repo root, with the active plan file path, the task ID, and the just-written state character (`X` or `!`):
135
+
136
+ `node <chosen-flags> scripts/conductor-db.mjs record "<plan_file>" "<task_id>" "<state>"`
137
+
138
+ All three arguments **must** be wrapped in double quotes exactly as shown. A repository path can contain spaces (e.g. `/Users/me/My Projects/repo/docs/plan.md`); unquoted, the shell word-splits it into several argv entries and the recorder sees `!== 3` positionals, silently rejecting a legitimate write. `--no-warnings` (in both probe and launch) suppresses Node's `ExperimentalWarning: SQLite is an experimental feature` line so it never pollutes hook stderr; it does not affect the recorder's own `CONDUCTOR_DB:` diagnostics (those are direct `process.stderr` writes, not process warnings).
139
+
140
+ The recorder self-initializes `.conductor/cache.db`, upserts the row, and exits 0 on every path. If the launch fails for any reason (permission error, unexpected abort), it is non-fatal: log a warning and continue. The plan file is the authoritative state record.
141
+
142
+ After the hook: if the task state is `[!]`, halt with the failure report from Step 5.
143
+
144
+ ### Repeat from Step 1.
145
+
146
+ ### Error Reference
147
+
148
+ | Condition | Action |
149
+ |-----------|--------|
150
+ | Verify drift < 5 | Discard line, return to Step 1 |
151
+ | Verify drift >= 5 consecutive | Halt; `VERIFY_DRIFT_EXCEEDED` |
152
+ | Pre-flip uniqueness != 1 | Halt; duplicate ID report |
153
+ | Pre-flip Edit no-match < 3 (same task) | Return to Step 1 |
154
+ | Pre-flip Edit no-match >= 3 (same task) | Mark `[!]`, halt |
155
+ | Post-flip Edit no-match | Halt; manual resolution |
156
+ | Task execution failure | Mark `[>]` → `[!]`, halt |
157
+ | Hook write failure | Log warning, continue |
158
+ | `[>]` prerequisite | Halt; `PREREQUISITE_IN_PROGRESS`; report task ID |
159
+ | `DEPENDENCY_FAILED` | Halt; report failed prerequisite |
160
+ | `SCAN_LIMIT_EXCEEDED` | Halt; report blocked task list |
161
+
162
+ ---
163
+
164
+ Confirm between tasks unless the developer explicitly says to proceed without confirmation.
@@ -0,0 +1,84 @@
1
+ ---
2
+ description: "(Conductor) Initialize or re-sync the project environment"
3
+ ---
4
+
5
+ ## Step 1 — Detect project state
6
+
7
+ List files in the project (exclude `.git/`, `.claude/`, `node_modules/`, and dot-files, max depth 3). Count source files found.
8
+
9
+ If the count is 0 or only `CLAUDE.md` / config files exist, treat this as a **new/empty project** (`IS_NEW=true`). Otherwise set `IS_NEW=false`.
10
+
11
+ ## Step 2 — Auto-detect and collect project identity
12
+
13
+ Check if `scripts/detect-stack.mjs` exists in the project root. If it does, run:
14
+
15
+ ```bash
16
+ node scripts/detect-stack.mjs "$PWD"
17
+ ```
18
+
19
+ **Environment flags:** `CC_GLOB_DEPTH` and any other `CC_*` env vars the user may have set are automatically inherited by the child `node` process — no explicit export or forwarding is required. The `/cc-init` command must NOT reset or unset these variables before calling detect-stack.
20
+
21
+ Capture the JSON output. For each field in the JSON (name, description, stack, build, test, lint, format, setup), check the corresponding line in CLAUDE.md:
22
+ - If the CLAUDE.md line contains `<command>` (any case) or is blank after `Key:` → replace with the detected value using a single `Edit` call.
23
+ - If the CLAUDE.md line already has a non-placeholder value → skip (never overwrite).
24
+
25
+ Apply all replacements in a **single `Edit` call** after collecting all detected values.
26
+
27
+ If `scripts/detect-stack.mjs` is missing or returns `{}`, skip auto-detection.
28
+
29
+ After auto-detection (or if skipped), check which identity fields remain blank:
30
+
31
+ Read `CLAUDE.md`. Check the `## Project Identity` section.
32
+
33
+ If **Name** is still empty, ask the user all of these questions at once (not one at a time):
34
+
35
+ 1. What is the project name?
36
+ 2. One sentence: what does it do?
37
+ 3. Primary tech stack (e.g. "TypeScript + React", "Python + FastAPI") — **only ask if `IS_NEW=false` AND stack was not auto-detected**
38
+ 4. Response language preference? (default: `en` — only ask if context suggests otherwise)
39
+
40
+ If Name was already filled (by auto-detection or previous run), skip directly to Step 3 without asking.
41
+
42
+ Once any manual fields are collected, update CLAUDE.md with a single `Edit` call covering all remaining blank fields.
43
+
44
+ **CI mode:** If `CI=true` or stdin is not a TTY, skip all interactive questions. Leave unresolved `<command>` placeholders in place.
45
+
46
+ ## Step 3 — Stack detection *(skip if IS_NEW=true)*
47
+
48
+ Run `/cc-stack`. Wait for stack profile confirmation before continuing.
49
+
50
+ ## Step 4 — Memory checkpoint *(skip if IS_NEW=true)*
51
+
52
+ Run `/cc-checkpoint`. Persist current architectural state to `.claude/memory/project.md`.
53
+
54
+ ## Step 5 — Graph sync *(skip if IS_NEW=true)*
55
+
56
+ Run `/graphify .` to build or refresh the project knowledge graph from the current working directory.
57
+
58
+ ## Step 6 — Hook integrity check
59
+
60
+ Verify `.claude/hooks/pre-tool-use.sh` exists and is executable:
61
+
62
+ ```bash
63
+ HOOK=".claude/hooks/pre-tool-use.sh"
64
+ if [ ! -f "$HOOK" ]; then
65
+ echo "⚠️ Hook missing: $HOOK"
66
+ echo "Run: bash install.sh (or copy from project-template/.claude/hooks/)"
67
+ exit 1
68
+ fi
69
+ [ -x "$HOOK" ] || chmod +x "$HOOK"
70
+ echo "✓ Hook OK: $HOOK"
71
+ ```
72
+
73
+ If the hook file is absent, stop and report. Do not proceed silently.
74
+
75
+ ## Step 7 — Confirm
76
+
77
+ Report:
78
+ - Project identity: [name / stack / language — written to CLAUDE.md]
79
+ - Stack profile loaded: [name / skipped — new project]
80
+ - Memory checkpoint: [saved / skipped — new project]
81
+ - Graph: [built / refreshed / skipped — new project]
82
+ - Hook: [OK / MISSING]
83
+
84
+ `/cc-init complete.`
@@ -0,0 +1,114 @@
1
+ ---
2
+ description: "(Conductor) Map implementation steps from an approved spec"
3
+ ---
4
+
5
+ ## Phase entry - Resume Read
6
+
7
+ Before doing anything else, restore any stored context for the current commit by running `scripts/resume-read.mjs`. It resolves the current git hash, prefers a valid DB snapshot (`conductor-db get-snapshot`), falls back to the `.claude/memory/session-snapshot.json` handoff file, and prints a `RESUME_HIT` block on a hit / nothing on a miss. Capture its stdout **and** its exit code with the canonical per-platform form (each first probes for `node` and treats its absence as a clean miss, never an error):
8
+
9
+ - **Unix / Git Bash:**
10
+ ```sh
11
+ if command -v node >/dev/null 2>&1; then
12
+ resume_out="$(node scripts/resume-read.mjs 2>>.conductor/last-write.log)"; resume_rc=$?
13
+ else resume_rc=3; resume_out=""; fi
14
+ ```
15
+ - **PowerShell:**
16
+ ```powershell
17
+ if (Get-Command node -ErrorAction SilentlyContinue) {
18
+ $__eap = $ErrorActionPreference; $ErrorActionPreference = 'Continue'
19
+ if (Test-Path variable:PSNativeCommandUseErrorActionPreference) {
20
+ $__nap = $PSNativeCommandUseErrorActionPreference; $PSNativeCommandUseErrorActionPreference = $false
21
+ }
22
+ try {
23
+ $resume_out = node scripts/resume-read.mjs 2>> .conductor/last-write.log; $resume_rc = $LASTEXITCODE
24
+ } catch { $resume_rc = 3; $resume_out = "" }
25
+ finally {
26
+ $ErrorActionPreference = $__eap
27
+ if (Test-Path variable:__nap) { $PSNativeCommandUseErrorActionPreference = $__nap }
28
+ }
29
+ } else { $resume_rc = 3; $resume_out = "" }
30
+ ```
31
+
32
+ Branch on `resume_rc` - **only `0` and `4` are meaningful; every other code proceeds fresh:**
33
+
34
+ - **`0`** → parse the captured block and adopt it as this phase's starting context, then echo one banner to the user: `> Resumed from stored snapshot @ <commit> (phase: <phase>)`, appending ` (checkpoint prose available)` when the block reports `prose: available`. Parsing (the command owns normalization): split on `\n`; strip a trailing `\r` from every line; drop leading/trailing wholly-blank lines; require `lines[0].trim() === 'RESUME_HIT'` (anything else = miss); `key: value` lines split on the first `': '` (both sides trimmed); the `pending:` block is every subsequent `^\s*-\s+` line up to the first blank line or EOF, each item trimmed. Unknown keys are ignored. In PowerShell, `node …` binds `string[]` for multi-line output - normalize with `$lines = @($resume_out)`; a `$null`/empty capture with `resume_rc = 3` is a miss.
35
+ - **`4`** → **operational halt.** Do not run this phase's normal work. Emit exactly: `SNAP_INVALID: corrupt handoff at .claude/memory/session-snapshot.json - inspect or remove it, then re-run.` and enter standby awaiting user action. The corrupt file is left on disk (the script did not delete it).
36
+ - **`3` or any other code** → **proceed fresh** (clean miss, bypass, degrade, absent `node`, or any unexpected runtime code). Ignore the capture.
37
+
38
+ `resume-read.mjs` writes its own trace lines to `.conductor/last-write.log` via `appendFileSync`; the `2>>` redirect above only sinks the incidental exit-4 halt reason away from the UI - it is not the trace channel.
39
+
40
+ ---
41
+
42
+ ## Phase 0 — Skill activation
43
+
44
+ Before doing anything else, invoke both skills in order:
45
+
46
+ ```
47
+ Skill({ skill: "writing-plans", args: "$ARGUMENTS" })
48
+ Skill({ skill: "critical-review" })
49
+ ```
50
+
51
+ `writing-plans` structures the format and sequencing strategy. `critical-review` Phase 1 then runs the Pre-Flight Analysis on the implementation approach — surface failure points and boundary conditions before committing to an ordered step list. Do not generate steps until both have completed.
52
+
53
+ ---
54
+
55
+ Require an approved spec before starting. If no spec is in `.claude/memory/project.md` or in the recent conversation, stop and say:
56
+ "No approved spec found. Run `/cc-spec [name]` first."
57
+
58
+ Read `.claude/memory/project.md` and this project's `CLAUDE.md` before doing anything else.
59
+
60
+ **Map the codebase structure** before reading any file content:
61
+ - List directories
62
+ - Identify files related to the spec using grep, not reads
63
+ - Note existing patterns to follow
64
+
65
+ **Generate a plan with:**
66
+
67
+ ## Task ID Requirements
68
+
69
+ Every task checkbox line must carry a unique alphanumeric ID:
70
+
71
+ - [ ] [T-001] Top-level task
72
+ - [ ] [T-001-A] Sub-task A
73
+ - [ ] [T-001-A-1] Sub-sub-task
74
+ - [ ] [T-002] Next top-level task
75
+
76
+ Rules:
77
+ - Minimum 3 digits (`T-001`); no upper bound (`T-1000` is valid)
78
+ - Suffix depth is unlimited: `T-NNN(-[A-Z0-9]+)*`
79
+ - IDs must be unique within the file; verify before saving; no two tasks may share the same ID
80
+ - Generated checkbox lines must use plain ASCII `[ ]` (U+0020 space only between brackets); no Unicode invisible characters
81
+ - Apply to all generated task lines only; do not add IDs retroactively to existing plan files
82
+
83
+ ## Ordered Steps
84
+
85
+ Each step must include:
86
+ - Exact file path(s)
87
+ - Action (create / modify / delete)
88
+ - What changes and why
89
+ - Whether it has a dependency on a previous step
90
+
91
+ ## Test List
92
+ - [ ] Unit tests for [unit]
93
+ - [ ] Integration test for [seam]
94
+ - [ ] E2E test if UI is affected
95
+
96
+ ## Commit Order
97
+ [Which steps to group into commits]
98
+
99
+ ## Identified Risks
100
+ [What could go wrong and how to catch it early]
101
+
102
+ ---
103
+
104
+ Execute one step at a time. Confirm between steps unless the developer explicitly says to proceed without confirmation.
105
+
106
+ ---
107
+
108
+ ## Phase exit
109
+
110
+ Once the plan is approved and saved, instruct the user:
111
+
112
+ > "Plan complete. Run `/cc-compact` now before starting implementation."
113
+
114
+ Do not proceed to implementation without user confirmation that `/cc-compact` has been run.
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: "(Conductor) Refactor a file or module for clarity and simplicity"
3
+ ---
4
+
5
+ ## Phase 0 — Skill activation
6
+
7
+ Invoke both skills before doing anything else:
8
+
9
+ ```
10
+ Skill({ skill: "code-simplifier", args: "$ARGUMENTS" })
11
+ Skill({ skill: "subagent-driven-development", args: "$ARGUMENTS" })
12
+ ```
13
+
14
+ `code-simplifier` defines the refactoring rules to apply. `subagent-driven-development` governs how to delegate each step to sub-agents — one per change, keeping the main context clean.
15
+
16
+ ---
17
+
18
+ Diagnose the target file or module:
19
+
20
+ **Complexity issues found:**
21
+ - Functions over 30 lines: [list with line numbers]
22
+ - Nesting over 3 levels: [list with line numbers]
23
+ - Classes with 5+ dependencies: [list]
24
+ - Layers that only delegate: [list]
25
+ - Misleading names: [list]
26
+
27
+ Generate a refactor plan: ordered list of changes, one per step.
28
+
29
+ For each step:
30
+ - What changes (exact file:line range)
31
+ - Why (complexity signal it resolves)
32
+ - Risk (what could break)
33
+
34
+ **Execute one change at a time.** After each:
35
+ 1. Run the test suite
36
+ 2. Report: tests passed / failed
37
+ 3. Confirm before the next step
38
+
39
+ **Final report:**
40
+ - Before: [line count, complexity metrics]
41
+ - After: [line count, complexity metrics]
42
+ - Test status: [passed / N failed]