@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.
- package/LICENSE +185 -0
- package/README.md +314 -0
- package/bin/code-conductor.mjs +133 -0
- package/global/CLAUDE.md +93 -0
- package/global/commands/cc-checkpoint.md +50 -0
- package/global/commands/cc-compact.md +49 -0
- package/global/commands/cc-lang.md +32 -0
- package/global/commands/cc-stack.md +69 -0
- package/global/hooks/graphify-ast-refresh.py +81 -0
- package/global/hooks/verbosity-remind.sh +372 -0
- package/global/memory/personal.md +24 -0
- package/global/memory/verbosity.md +7 -0
- package/global/settings.json +24 -0
- package/lib/installer/config.mjs +51 -0
- package/lib/installer/deploy.mjs +76 -0
- package/lib/installer/env.mjs +35 -0
- package/lib/installer/settings.mjs +77 -0
- package/package.json +34 -0
- package/project-template/.claude/commands/cc-debug.md +42 -0
- package/project-template/.claude/commands/cc-docs.md +49 -0
- package/project-template/.claude/commands/cc-implement.md +164 -0
- package/project-template/.claude/commands/cc-init.md +84 -0
- package/project-template/.claude/commands/cc-plan.md +114 -0
- package/project-template/.claude/commands/cc-refactor.md +42 -0
- package/project-template/.claude/commands/cc-resume.md +142 -0
- package/project-template/.claude/commands/cc-review.md +77 -0
- package/project-template/.claude/commands/cc-spec.md +138 -0
- package/project-template/.claude/commands/cc-test.md +56 -0
- package/project-template/.claude/hooks/context-guard.ps1 +55 -0
- package/project-template/.claude/hooks/context-guard.sh +43 -0
- package/project-template/.claude/hooks/post-compact.ps1 +41 -0
- package/project-template/.claude/hooks/post-compact.sh +36 -0
- package/project-template/.claude/hooks/pre-tool-use.sh +81 -0
- package/project-template/.claude/hooks/verbosity-remind.sh +168 -0
- package/project-template/.claude/memory/context-threshold.txt +1 -0
- package/project-template/.claude/memory/project.md +48 -0
- package/project-template/.claude/settings.json +52 -0
- package/project-template/CLAUDE.md +104 -0
- package/skills/agent-delegation.md +44 -0
- package/skills/code-simplifier.md +124 -0
- package/skills/critical-review.md +75 -0
- package/skills/memory-first.md +50 -0
- package/skills/verbosity.md +30 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Same exit-0 invariant as global hook — must never exit non-zero.
|
|
3
|
+
# See global hook comment for full design rationale.
|
|
4
|
+
trap 'exit 0' EXIT ERR
|
|
5
|
+
|
|
6
|
+
# CI/CD bypass — exit before any I/O
|
|
7
|
+
case "${CC_VERBOSITY_SKIP:-0}" in
|
|
8
|
+
1|true|yes|on|TRUE|YES|ON|True|Yes|On) exit 0 ;;
|
|
9
|
+
esac
|
|
10
|
+
|
|
11
|
+
# Named traversal cap (same value as global hook; defined separately per-script
|
|
12
|
+
# so each hook is independently executable without sourcing the other).
|
|
13
|
+
readonly _VERBOSITY_TRAVERSAL_CAP=40
|
|
14
|
+
|
|
15
|
+
# $HOME null guard
|
|
16
|
+
if [ -z "${HOME:-}" ]; then
|
|
17
|
+
printf '\n[VERBOSITY:MIN] One sentence. [CHANGES] file list only. No prose.\n'
|
|
18
|
+
exit 0
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
# $PWD null guard
|
|
22
|
+
_start="${PWD:-}"
|
|
23
|
+
_skip_traversal=0
|
|
24
|
+
[ -z "$_start" ] && _skip_traversal=1
|
|
25
|
+
|
|
26
|
+
# Log setup
|
|
27
|
+
_SCOPE="project"
|
|
28
|
+
_logdir="$HOME/.claude/logs"
|
|
29
|
+
_logfile="$_logdir/verbosity-hook.log"
|
|
30
|
+
_log_ok=0
|
|
31
|
+
if [ -e "$_logdir" ] && [ ! -d "$_logdir" ]; then
|
|
32
|
+
echo "[verbosity-remind] log dir blocked by non-directory: $_logdir" >&2
|
|
33
|
+
elif mkdir -p "$_logdir" 2>/dev/null && [ -w "$_logdir" ]; then
|
|
34
|
+
if [ -e "$_logfile" ] && [ ! -f "$_logfile" ]; then
|
|
35
|
+
echo "[verbosity-remind] log file path blocked by directory: $_logfile" >&2
|
|
36
|
+
else
|
|
37
|
+
_log_ok=1
|
|
38
|
+
fi
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
_write_log() {
|
|
42
|
+
(( _log_ok )) || return 0
|
|
43
|
+
_logsize=0
|
|
44
|
+
[ -f "$_logfile" ] && _logsize=$(wc -c < "$_logfile" 2>/dev/null || echo 0)
|
|
45
|
+
if [ "${_logsize:-0}" -gt 1048576 ]; then
|
|
46
|
+
# Log rotation (same strategy as global hook): `true > "$_logfile"` is
|
|
47
|
+
# POSIX-portable. See global hook _write_log comment for full rationale.
|
|
48
|
+
true > "$_logfile" 2>/dev/null && \
|
|
49
|
+
printf '%s [%s] log rotated at 1 MB ceiling\n' \
|
|
50
|
+
"$(date '+%Y-%m-%d %H:%M:%S')" "$_SCOPE" >> "$_logfile" 2>/dev/null
|
|
51
|
+
# Fall through — write current message to freshly truncated file.
|
|
52
|
+
fi
|
|
53
|
+
# Concurrent writes: POSIX O_APPEND (>>) serialises each write() atomically for
|
|
54
|
+
# payloads under PIPE_BUF (~512 B). A single log line is well under that limit.
|
|
55
|
+
# The size check is a non-atomic TOCTOU; see global hook for the full note.
|
|
56
|
+
printf '%s [%s] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$_SCOPE" "$1" >> "$_logfile" 2>/dev/null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# ── Stage 2: cascading memory resolution (no Stage 1 — project hook IS the authority) ──
|
|
60
|
+
_mem_file=""
|
|
61
|
+
if [ "$_skip_traversal" = "0" ]; then
|
|
62
|
+
# Cycle safety: same guarantee as global hook — ${_dir%/*} is pure string
|
|
63
|
+
# truncation; symlink cycles cannot occur. The $_VERBOSITY_TRAVERSAL_CAP-iteration
|
|
64
|
+
# cap handles degenerate deep paths. See global hook for the full cycle-safety note.
|
|
65
|
+
_dir="$_start"; _prev=""; _iters=0; _cap=$_VERBOSITY_TRAVERSAL_CAP
|
|
66
|
+
while [ "$_dir" != "$_prev" ] && (( _iters < _cap )); do
|
|
67
|
+
_f="$_dir/.claude/memory/verbosity.md"
|
|
68
|
+
if [ -f "$_f" ] && [ -r "$_f" ]; then
|
|
69
|
+
# Symlink safety (same rule as global hook): skip verbosity.md files that
|
|
70
|
+
# resolve to sensitive system paths to prevent unintended file reads.
|
|
71
|
+
if [ -L "$_f" ]; then
|
|
72
|
+
_resolved=$(readlink -f "$_f" 2>/dev/null || readlink "$_f" 2>/dev/null || echo "")
|
|
73
|
+
case "$_resolved" in
|
|
74
|
+
/etc/*|/proc/*|/sys/*|/dev/*)
|
|
75
|
+
_write_log "WARN: verbosity.md at $_f resolves to '$_resolved' — skipping"
|
|
76
|
+
_prev="$_dir"; _dir="${_dir%/*}"; [ -z "$_dir" ] && _dir="/"
|
|
77
|
+
(( _iters++ )) || true; continue ;;
|
|
78
|
+
esac
|
|
79
|
+
fi
|
|
80
|
+
_mem_file="$_f"
|
|
81
|
+
break
|
|
82
|
+
fi
|
|
83
|
+
_prev="$_dir"
|
|
84
|
+
_dir="${_dir%/*}"
|
|
85
|
+
[ -z "$_dir" ] && _dir="/"
|
|
86
|
+
(( _iters++ )) || true
|
|
87
|
+
done
|
|
88
|
+
(( _iters >= _cap )) && [ -z "$_mem_file" ] && \
|
|
89
|
+
_write_log "traversal cap (${_cap}) reached; no verbosity.md found"
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
[ -z "$_mem_file" ] && _mem_file="$HOME/.claude/memory/verbosity.md"
|
|
93
|
+
|
|
94
|
+
# ── Extraction loop ───────────────────────────────────────────────────────────
|
|
95
|
+
_in_fence=0; _in_fm=0; LEVEL=""; _lineno=0
|
|
96
|
+
if [ -f "$_mem_file" ] && [ -r "$_mem_file" ]; then
|
|
97
|
+
while IFS= read -r _line || [ -n "$_line" ]; do
|
|
98
|
+
_lineno=$(( _lineno + 1 ))
|
|
99
|
+
[ "$_lineno" = "1" ] && _line="${_line#$'\xef\xbb\xbf'}"
|
|
100
|
+
_line="${_line%$'\r'}"
|
|
101
|
+
if [ "$_lineno" = "1" ] && [ "$_line" = "---" ]; then
|
|
102
|
+
_in_fm=1; continue
|
|
103
|
+
fi
|
|
104
|
+
if [ "$_in_fm" = "1" ]; then
|
|
105
|
+
case "$_line" in
|
|
106
|
+
---|\.\.\.) _in_fm=0 ;;
|
|
107
|
+
esac
|
|
108
|
+
continue
|
|
109
|
+
fi
|
|
110
|
+
case "$_line" in
|
|
111
|
+
'```'*|'~~~'*) (( _in_fence = 1 - _in_fence )) || true ;;
|
|
112
|
+
VERBOSITY:*)
|
|
113
|
+
(( _in_fence )) && continue
|
|
114
|
+
LEVEL="${_line#VERBOSITY:}"
|
|
115
|
+
LEVEL="${LEVEL#"${LEVEL%%[! ]*}"}"
|
|
116
|
+
LEVEL="${LEVEL%% #*}" # strip " # comment" (space+hash); bare # not treated as delimiter
|
|
117
|
+
LEVEL="${LEVEL%%[[:space:]]*}" # strip remaining trailing whitespace
|
|
118
|
+
break
|
|
119
|
+
;;
|
|
120
|
+
esac
|
|
121
|
+
done < "$_mem_file"
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
# Recovery pass — unclosed fence
|
|
125
|
+
if [ -z "$LEVEL" ] && [ "$_in_fence" = "1" ]; then
|
|
126
|
+
mkdir -p "$HOME/.claude/logs" 2>/dev/null
|
|
127
|
+
# .verbosity-fence-warned: 60-min TTL, per-machine. See global hook for full lifecycle note.
|
|
128
|
+
find "$HOME/.claude/logs/.verbosity-fence-warned" -mmin -60 2>/dev/null | grep -q . || {
|
|
129
|
+
echo "[verbosity-remind] unclosed fence in $_mem_file; using recovery pass" >&2
|
|
130
|
+
touch "$HOME/.claude/logs/.verbosity-fence-warned" 2>/dev/null
|
|
131
|
+
}
|
|
132
|
+
while IFS= read -r _line || [ -n "$_line" ]; do
|
|
133
|
+
_line="${_line%$'\r'}"
|
|
134
|
+
case "$_line" in
|
|
135
|
+
VERBOSITY:*)
|
|
136
|
+
LEVEL="${_line#VERBOSITY:}"
|
|
137
|
+
LEVEL="${LEVEL#"${LEVEL%%[! ]*}"}"
|
|
138
|
+
LEVEL="${LEVEL%% #*}" # strip " # comment" (space+hash only)
|
|
139
|
+
LEVEL="${LEVEL%%[[:space:]]*}" # strip remaining trailing whitespace
|
|
140
|
+
break
|
|
141
|
+
;;
|
|
142
|
+
esac
|
|
143
|
+
done < "$_mem_file"
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# ── Normalization ─────────────────────────────────────────────────────────────
|
|
147
|
+
# Empty / whitespace-only verbosity.md: same recovery as global hook.
|
|
148
|
+
# LEVEL="" passes through normalization unchanged; Stage 3 sanity guard
|
|
149
|
+
# catches it via the wildcard branch and sets LEVEL="MIN". No extra guard needed.
|
|
150
|
+
case "$LEVEL" in
|
|
151
|
+
[Mm][Ii][Nn]) LEVEL="MIN" ;;
|
|
152
|
+
[Ii][Nn][Ff][Oo]) LEVEL="INFO" ;;
|
|
153
|
+
[Vv][Ee][Rr][Bb][Oo][Ss][Ee]) LEVEL="VERBOSE" ;;
|
|
154
|
+
esac
|
|
155
|
+
|
|
156
|
+
# ── Stage 3: sanity guard + emit ─────────────────────────────────────────────
|
|
157
|
+
case "$LEVEL" in
|
|
158
|
+
MIN|INFO|VERBOSE) ;;
|
|
159
|
+
*) LEVEL="MIN" ;;
|
|
160
|
+
esac
|
|
161
|
+
|
|
162
|
+
# Output is injected into Claude's prompt context. Use only printable ASCII —
|
|
163
|
+
# no ANSI escapes, control sequences, or non-ASCII bytes. See global hook note.
|
|
164
|
+
case "$LEVEL" in
|
|
165
|
+
MIN) printf '\n[VERBOSITY:MIN] One sentence. [CHANGES] file list only. No prose.\n' ;;
|
|
166
|
+
INFO) printf '\n[VERBOSITY:INFO] Bullet list max 5. [CHANGES]+[REASON] tags.\n' ;;
|
|
167
|
+
VERBOSE) printf '\n[VERBOSITY:VERBOSE] Full explanation. All tags active.\n' ;;
|
|
168
|
+
esac
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
25
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Project Memory
|
|
2
|
+
|
|
3
|
+
Shared team memory. Committed to git. Updated automatically by /checkpoint.
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
<!-- Set by /stack -->
|
|
7
|
+
|
|
8
|
+
## Architecture Decisions
|
|
9
|
+
<!-- Append by /checkpoint. Never delete entries. -->
|
|
10
|
+
|
|
11
|
+
### Checkpoint 2026-06-09 17:45
|
|
12
|
+
|
|
13
|
+
**BUG-001: Phase Boundary Compaction (/cc-compact) — v1.7.0**
|
|
14
|
+
|
|
15
|
+
- **Decided:** phase context clearing uses a dedicated `/cc-compact` command (not baked into phase commands, not an extension of `/cc-checkpoint`). One command, one invariant: serialize then prompt for `/compact`.
|
|
16
|
+
- **Decided:** snapshot schema is fixed and token-bounded (≤300 tokens): Phase, Commit (full SHA-1 via `git rev-parse HEAD`), Decisions (max 10), Pending, Files Touched, Constraints (max 5), Spec Reference. No freeform prose.
|
|
17
|
+
- **Decided:** snapshot file is `.claude/memory/session-snapshot.md`, gitignored, single instance (always overwritten).
|
|
18
|
+
- **Decided:** Destructive Read Invariant — every phase command that reads the snapshot must delete it immediately after reading. Deletion failure halts the command.
|
|
19
|
+
- **Decided:** Phase Handoff Enforcement uses decoupled conditions — turn count > 5 is the only blocking halt; absent snapshot is a read-if-present fallback, not a blocker (prevents infinite standby on fresh sessions).
|
|
20
|
+
- **Decided:** `/compact` is user-invoked, not agent-invoked. `/cc-compact` outputs a prompt; it does not call `/compact` itself.
|
|
21
|
+
- **Rejected:** extending `/cc-checkpoint` with phase-boundary semantics (blurs its purpose as a general decision-saver).
|
|
22
|
+
- **Rejected:** baking compaction logic directly into phase commands (harder to evolve independently).
|
|
23
|
+
|
|
24
|
+
**Files added/modified:**
|
|
25
|
+
- `global/commands/cc-compact.md` — new
|
|
26
|
+
- `project-template/.claude/commands/cc-implement.md` — new
|
|
27
|
+
- `project-template/.claude/commands/cc-spec.md` — DRI + exit prompt
|
|
28
|
+
- `project-template/.claude/commands/cc-plan.md` — enforcement + DRI + exit prompt
|
|
29
|
+
- `project-template/.claude/commands/cc-review.md` — enforcement + DRI
|
|
30
|
+
|
|
31
|
+
## Active Conventions
|
|
32
|
+
<!-- Project-specific conventions established in this codebase -->
|
|
33
|
+
|
|
34
|
+
- No em-dashes (—) anywhere in command files or docs — use hyphens (-) or colons (:).
|
|
35
|
+
- All phase command files use `## Phase entry - <Name>` and `## Phase exit` section headers (second-level).
|
|
36
|
+
- Spec files live in `docs/superpowers/specs/YYYY-MM-DD-<slug>-design.md` (force-added since `docs/` is gitignored).
|
|
37
|
+
- Plan files live in `docs/superpowers/plans/YYYY-MM-DD-<slug>.md` (force-added).
|
|
38
|
+
- VERSION file contains a single semver string. Minor bump for new behavioral features.
|
|
39
|
+
|
|
40
|
+
## Technical Debt
|
|
41
|
+
<!-- Known shortcuts, limitations, and deferred work -->
|
|
42
|
+
|
|
43
|
+
- `docs/` is in `.gitignore` but spec/plan files need to be tracked — currently force-added individually. Should add `!docs/superpowers/` exception to `.gitignore` to fix this properly (deferred).
|
|
44
|
+
- BUG-001 enforcement check relies on the agent counting turns correctly — no programmatic turn counter exists yet. FEAT-007 (token threshold auto-compaction) would make this structural.
|
|
45
|
+
- `/cc-compact` depends on the agent accurately recalling phase state from conversation context — no structured state extraction mechanism exists yet (FEAT-005 SQLite layer would fix this).
|
|
46
|
+
|
|
47
|
+
## Workarounds
|
|
48
|
+
<!-- Non-obvious solutions and why they exist -->
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Write|Edit|create_file|write_file",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash -c 'h=\".claude/hooks/pre-tool-use.sh\"; [ -f \"$h\" ] && bash \"$h\" || { echo \"⚠ Hook missing — run /cc-init to repair\"; exit 0; }'"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PostCompact": [
|
|
15
|
+
{
|
|
16
|
+
"hooks": [
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "bash -c 'h=\".claude/hooks/post-compact.sh\"; [ -f \"$h\" ] && bash \"$h\" || exit 0'"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "command",
|
|
23
|
+
"command": "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File \".claude/hooks/post-compact.ps1\""
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"UserPromptSubmit": [
|
|
29
|
+
{
|
|
30
|
+
"matcher": "",
|
|
31
|
+
"hooks": [
|
|
32
|
+
{
|
|
33
|
+
"type": "command",
|
|
34
|
+
"command": "bash -c 'set +e; _dir=\"${PWD:-}\"; _prev=\"\"; _iters=0; while [ \"$_dir\" != \"$_prev\" ] && [ \"$_iters\" -lt 40 ]; do _h=\"$_dir/.claude/hooks/verbosity-remind.sh\"; [ -f \"$_h\" ] && [ -r \"$_h\" ] && { bash \"$_h\"; exit $?; }; _prev=\"$_dir\"; _dir=\"${_dir%/*}\"; [ -z \"$_dir\" ] && _dir=/; _iters=$((_iters+1)); done; exit 0'"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"type": "command",
|
|
38
|
+
"command": "bash -c 'set +e; _dir=\"${PWD:-}\"; _prev=\"\"; _i=0; while [ \"$_dir\" != \"$_prev\" ] && [ \"$_i\" -lt 40 ]; do _h=\"$_dir/.claude/hooks/context-guard.sh\"; [ -f \"$_h\" ] && [ -r \"$_h\" ] && { CC_PROJECT_ROOT=\"$_dir\" bash \"$_h\"; exit $?; }; _prev=\"$_dir\"; _dir=\"${_dir%/*}\"; [ -z \"$_dir\" ] && _dir=/; _i=$((_i+1)); done; exit 0'"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "command",
|
|
42
|
+
"command": "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File \".claude/hooks/context-guard.ps1\""
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"permissions": {
|
|
49
|
+
"allow": [],
|
|
50
|
+
"deny": []
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Project Claude Configuration
|
|
2
|
+
|
|
3
|
+
Extends global CLAUDE.md. Project-specific rules take precedence over global ones.
|
|
4
|
+
|
|
5
|
+
## Project Identity
|
|
6
|
+
- Name:
|
|
7
|
+
- Description:
|
|
8
|
+
- Stack:
|
|
9
|
+
- Language: en
|
|
10
|
+
|
|
11
|
+
## Development Commands
|
|
12
|
+
- Build: <command>
|
|
13
|
+
- Test: <command>
|
|
14
|
+
- Lint: <command>
|
|
15
|
+
- Format: <command>
|
|
16
|
+
- Setup: <command>
|
|
17
|
+
|
|
18
|
+
## Architecture Notes
|
|
19
|
+
<!-- Key architectural decisions for this project -->
|
|
20
|
+
|
|
21
|
+
## Conventions
|
|
22
|
+
<!-- Project-specific conventions that override global defaults -->
|
|
23
|
+
|
|
24
|
+
## Out of Scope
|
|
25
|
+
<!-- Things Claude should not touch in this project -->
|
|
26
|
+
|
|
27
|
+
## Active Stack Profiles
|
|
28
|
+
<!-- cc-stack:managed: regenerated by /cc-stack, manual edits inside are overwritten -->
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Agent Identity
|
|
33
|
+
You are a Senior Full-Stack Architect and Orchestrator specialized in spec-driven, modular engineering. You delegate raw data processing to sub-agents, never guess when you can query, and never open a file when a targeted search suffices.
|
|
34
|
+
|
|
35
|
+
## Session Initialization
|
|
36
|
+
- At session start: use **Glob** (NEVER use Read) to check that `project.md` and
|
|
37
|
+
`graphify-out/graph.json` exist; run `/cc-init` if absent.
|
|
38
|
+
- NEVER read raw files under `graphify-out/` or `node_modules/` — Guard 4 blocks such
|
|
39
|
+
reads at the hook level. For graph queries, invoke the graphify skill:
|
|
40
|
+
`/graphify query "<question>"`.
|
|
41
|
+
- Do not accept implementation tasks without valid project memory and graph.
|
|
42
|
+
|
|
43
|
+
## Dynamic Specialization
|
|
44
|
+
| Mode | Trigger | Persona focus |
|
|
45
|
+
|---------------|-------------------------|----------------------------------------|
|
|
46
|
+
| BACKEND_ONLY | No frontend framework | API performance, DB integrity |
|
|
47
|
+
| FRONTEND_ONLY | No backend framework | Component modularity, ui-ux-pro-max |
|
|
48
|
+
| FULLSTACK | Both layers detected | Frontend/backend contract, type safety |
|
|
49
|
+
|
|
50
|
+
## Operational Philosophy
|
|
51
|
+
- Token efficiency: query the graph before reading; search before opening; never ingest what can be looked up.
|
|
52
|
+
- Modular autonomy: delegate raw output (grep, file content, intermediates) to sub-agents; keep main context clean.
|
|
53
|
+
- State synchronization: run /cc-checkpoint after feature completion and before /compact.
|
|
54
|
+
|
|
55
|
+
## Execution Rules
|
|
56
|
+
|
|
57
|
+
### Graph-First
|
|
58
|
+
Before modifying any file:
|
|
59
|
+
1. Query graphify-out/graph.json for all callers, dependents, and related nodes of the target symbol.
|
|
60
|
+
2. If graph absent, run /cc-init. Fallback: spawn Explore sub-agent (≤150 words, callers + file paths).
|
|
61
|
+
3. Open a file only when you have a specific line range. Always pass limit on files > 150 lines.
|
|
62
|
+
|
|
63
|
+
### Dependency Integrity
|
|
64
|
+
After modifying any method, variable, class, or component:
|
|
65
|
+
- Run a global grep for all usages of the modified element.
|
|
66
|
+
- Identify and repair broken references, import errors, and type mismatches within the same task scope.
|
|
67
|
+
- Report under [DEPS] tag.
|
|
68
|
+
|
|
69
|
+
### Sub-Agent Delegation
|
|
70
|
+
| Task | Sub-agent / Skill |
|
|
71
|
+
|----------------------------|---------------------------|
|
|
72
|
+
| Refactoring | code-simplifier skill |
|
|
73
|
+
| Frontend UI/UX | ui-ux-pro-max skill |
|
|
74
|
+
| Pre-flight / adversarial | critical-review skill |
|
|
75
|
+
| Graph querying | Explore sub-agent |
|
|
76
|
+
| Codebase exploration (3+) | Explore sub-agent |
|
|
77
|
+
| Parallel independent tasks | Multiple Agent calls |
|
|
78
|
+
|
|
79
|
+
## Response Tags
|
|
80
|
+
| Tag | When to use |
|
|
81
|
+
|--------------|----------------------------------------------------------------------------------------------------|
|
|
82
|
+
| [CHANGES] | Always — comma-separated list of modified files |
|
|
83
|
+
| [REASON] | Omitted in MIN mode — why a change was made, when rationale is non-obvious |
|
|
84
|
+
| [PLAN] | Omitted in MIN mode — ordered steps for multi-step changes |
|
|
85
|
+
| [DEPS] | Omitted in MIN mode — downstream references checked or repaired |
|
|
86
|
+
| [TESTS] | Omitted in MIN mode — test files affected or written |
|
|
87
|
+
| [BUG] | Always when a bug is found — format: `file:line — one-sentence description`. Never suppressed, including in MIN mode. |
|
|
88
|
+
| [VALIDATION] | After implementation tasks only — edge cases, risks, justification |
|
|
89
|
+
|
|
90
|
+
## Verbosity Protocol
|
|
91
|
+
VERBOSITY: MIN (default)
|
|
92
|
+
- One declarative sentence. No greeting. No intro. No filler. No "Sure!", "Of course!", "Here is…".
|
|
93
|
+
- [CHANGES] tag: modified file list only.
|
|
94
|
+
- [VALIDATION] tag: included after implementation tasks only (code changes, file rewrites, behavioral modifications); condensed to exactly three lines — one each for: edge cases covered, residual risks, justification. Omitted entirely for non-implementation tasks (file deletions, config-only chores, maintenance commits, pure documentation edits).
|
|
95
|
+
- [BUG] tag: always included in MIN mode when a bug is found; format: `[BUG] file:line — one-sentence description`. Never suppressed.
|
|
96
|
+
- All other tags ([REASON], [PLAN], [DEPS], [TESTS]) are omitted in MIN mode.
|
|
97
|
+
- Ambiguity: one clarifying question, nothing else.
|
|
98
|
+
|
|
99
|
+
## Hard Constraints
|
|
100
|
+
- Never hardcode secrets, tokens, passwords, or API keys.
|
|
101
|
+
- Never run destructive shell commands (rm -rf, git reset --hard, git push --force) without explicit user confirmation.
|
|
102
|
+
- Never skip the pre-tool-use.sh hook; if it blocks a tool invocation, investigate — do not bypass.
|
|
103
|
+
- Never write code without an approved /cc-spec; never implement without an approved /cc-plan.
|
|
104
|
+
- Never overwrite plan or tracking files in bulk; all state updates must be surgical single-line edits targeting one checkbox or field at a time (BUG-003 invariant).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-delegation
|
|
3
|
+
description: "Rules for when and how to spawn sub-agents: Explore for 3+ file reads, parallel agents for independent tasks, summaries only — raw output never enters main context"
|
|
4
|
+
type: skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Agent Delegation
|
|
8
|
+
|
|
9
|
+
Keep the main context clean. Raw file contents, grep output, and intermediate data never enter the main context. Sub-agents process data and return summaries only.
|
|
10
|
+
|
|
11
|
+
## When to Spawn
|
|
12
|
+
|
|
13
|
+
### Explore Sub-Agent
|
|
14
|
+
**Condition:** Task requires reading 3+ files to answer one question, or codebase exploration precedes implementation.
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
// Use the Agent tool with these parameters:
|
|
18
|
+
Agent({
|
|
19
|
+
subagent_type: "Explore",
|
|
20
|
+
description: "<10-word description of the lookup>",
|
|
21
|
+
prompt: "<question>. Search across relevant files. Return a summary of ≤200 words. Do not include raw file contents."
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Parallel Agents
|
|
26
|
+
**Condition:** 2+ implementation tasks with no shared state, each describable independently.
|
|
27
|
+
|
|
28
|
+
Send both Agent calls in a single message so they run in parallel:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// Use the Agent tool twice in the same message — they run in parallel:
|
|
32
|
+
Agent({ description: "Task A", prompt: "... Return a summary of ≤200 words." })
|
|
33
|
+
Agent({ description: "Task B", prompt: "... Return a summary of ≤200 words." })
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Output Contract
|
|
37
|
+
- Every sub-agent returns ≤200 words to the main context.
|
|
38
|
+
- The main context acts only on summaries, not raw data.
|
|
39
|
+
- If a sub-agent needs user input, it surfaces one question to the main context and stops.
|
|
40
|
+
|
|
41
|
+
## When NOT to Spawn
|
|
42
|
+
- Single Grep or Glob can answer the question.
|
|
43
|
+
- Answer is already in `.claude/memory/project.md`.
|
|
44
|
+
- Task requires back-and-forth with the user (stay inline).
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Code Simplifier
|
|
2
|
+
|
|
3
|
+
**Always active.** Apply these rules to every piece of code written or reviewed.
|
|
4
|
+
|
|
5
|
+
## Rules
|
|
6
|
+
|
|
7
|
+
### 1. No Speculative Abstractions
|
|
8
|
+
Solve today's problem. Do not build for hypothetical future requirements.
|
|
9
|
+
|
|
10
|
+
❌ Bad:
|
|
11
|
+
```typescript
|
|
12
|
+
interface DataProcessor<T, R> {
|
|
13
|
+
process(data: T): R;
|
|
14
|
+
validate(data: T): boolean;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
✅ Good:
|
|
19
|
+
```typescript
|
|
20
|
+
function parseUserInput(raw: string): User { ... }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 2. No Premature Layers
|
|
24
|
+
Add a layer only when it carries real logic — not to "separate concerns" theoretically.
|
|
25
|
+
|
|
26
|
+
❌ Bad:
|
|
27
|
+
```typescript
|
|
28
|
+
class UserRepository {
|
|
29
|
+
constructor(private db: UserDataAccessLayer) {}
|
|
30
|
+
findById(id: string) { return this.db.findById(id); }
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
✅ Good:
|
|
35
|
+
```typescript
|
|
36
|
+
async function getUserById(db: Database, id: string): Promise<User> {
|
|
37
|
+
return db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. No Single-Implementation Interfaces
|
|
42
|
+
Don't create an interface for a type that will only ever have one implementation.
|
|
43
|
+
|
|
44
|
+
❌ Bad: `interface Logger { log(msg: string): void }`
|
|
45
|
+
✅ Good: Use the class directly, or a plain function.
|
|
46
|
+
|
|
47
|
+
### 4. Functions Do One Thing (Max 30 Lines)
|
|
48
|
+
If a function needs a comment to describe what a section does, that section should be its own function.
|
|
49
|
+
|
|
50
|
+
### 5. No Defensive Code for Impossible Cases
|
|
51
|
+
Don't validate inputs that can't be wrong (internal calls, typed parameters, framework guarantees).
|
|
52
|
+
|
|
53
|
+
❌ Bad:
|
|
54
|
+
```typescript
|
|
55
|
+
function add(a: number, b: number): number {
|
|
56
|
+
if (typeof a !== 'number') throw new Error('a must be a number');
|
|
57
|
+
return a + b;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
✅ Good:
|
|
62
|
+
```typescript
|
|
63
|
+
function add(a: number, b: number): number {
|
|
64
|
+
return a + b;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 6. No Design Patterns by Default
|
|
69
|
+
Use a pattern only when it solves a specific pain you have today.
|
|
70
|
+
|
|
71
|
+
### 7. Flat Over Nested
|
|
72
|
+
Use guard clauses and early returns instead of nesting.
|
|
73
|
+
|
|
74
|
+
❌ Bad:
|
|
75
|
+
```typescript
|
|
76
|
+
function process(user: User | null) {
|
|
77
|
+
if (user) {
|
|
78
|
+
if (user.isActive) {
|
|
79
|
+
if (user.hasPermission) {
|
|
80
|
+
doWork(user);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
✅ Good:
|
|
88
|
+
```typescript
|
|
89
|
+
function process(user: User | null) {
|
|
90
|
+
if (!user) return;
|
|
91
|
+
if (!user.isActive) return;
|
|
92
|
+
if (!user.hasPermission) return;
|
|
93
|
+
doWork(user);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 8. Descriptive Names
|
|
98
|
+
No `Base`, `Abstract`, `Generic`, `Manager`, `Handler`, `Service`, `Helper`, `Util`.
|
|
99
|
+
|
|
100
|
+
### 9. Constants Only When Used 2+ Places or Have Domain Meaning
|
|
101
|
+
❌ Bad: `const ONE = 1`
|
|
102
|
+
✅ Good: `const MAX_RETRY_ATTEMPTS = 3`
|
|
103
|
+
|
|
104
|
+
### 10. Comments Explain Why, Never What
|
|
105
|
+
❌ Bad: `// increment counter`
|
|
106
|
+
✅ Good: `// retry limit matches SLA from the payments contract`
|
|
107
|
+
|
|
108
|
+
## Complexity Signals — Stop and Simplify
|
|
109
|
+
|
|
110
|
+
When you see any of these, stop and refactor before adding more code:
|
|
111
|
+
|
|
112
|
+
- Class with 5+ constructor dependencies
|
|
113
|
+
- Function over 30 lines
|
|
114
|
+
- 3+ levels of nesting
|
|
115
|
+
- A layer that only delegates to the layer below
|
|
116
|
+
- A name containing Base, Abstract, Generic, Manager, or Handler
|
|
117
|
+
|
|
118
|
+
## When Complexity IS Justified
|
|
119
|
+
|
|
120
|
+
Only add abstraction when:
|
|
121
|
+
- Multiple real implementations exist today (not "might exist someday")
|
|
122
|
+
- Domain rules are genuinely complex and need encapsulation
|
|
123
|
+
- A documented performance constraint requires it
|
|
124
|
+
- The pattern prevents a bug class that has already occurred in this codebase
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: critical-review
|
|
3
|
+
description: "4-phase adversarial review protocol: pre-flight analysis, adversarial execution check, self-correction loop, and [VALIDATION] report"
|
|
4
|
+
type: skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Critical Review Protocol
|
|
8
|
+
|
|
9
|
+
Apply this protocol to every implementation task. Do not skip phases.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Phase 1 — Pre-Flight Analysis
|
|
14
|
+
|
|
15
|
+
Before writing any code, perform a Vulnerability Assessment on the proposed solution. Do not proceed to implementation until all three are answered:
|
|
16
|
+
|
|
17
|
+
**Happy Path** — Describe the most common successful execution flow in one sentence.
|
|
18
|
+
|
|
19
|
+
**Failure Points** — Where is this logic most likely to break? List: race conditions, null/undefined references, network timeouts, missing auth, unhandled promise rejections, type coercion surprises.
|
|
20
|
+
|
|
21
|
+
**Boundary Conditions** — What inputs or volume break assumptions? List: empty arrays, zero values, extremely large payloads, concurrent calls, missing environment variables.
|
|
22
|
+
|
|
23
|
+
Present the Pre-Flight Analysis and wait for confirmation before implementing.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Phase 2 — Execution & Adversarial Review
|
|
28
|
+
|
|
29
|
+
After completing the initial implementation, switch to an Adversarial Review persona. Run each check:
|
|
30
|
+
|
|
31
|
+
### RESILIENCE
|
|
32
|
+
Does the system fail gracefully or crash silently when a dependency fails or input is malformed? Look for:
|
|
33
|
+
- Caught errors that swallow the stack trace
|
|
34
|
+
- Unchecked nulls after async calls
|
|
35
|
+
- Missing fallbacks on external API responses
|
|
36
|
+
|
|
37
|
+
### EFFICIENCY
|
|
38
|
+
Is this the best possible outcome? Flag:
|
|
39
|
+
- Redundant loops or duplicate traversals
|
|
40
|
+
- Deep nesting (>3 levels) replaceable by early returns
|
|
41
|
+
- High cyclomatic complexity (branches > 5 in one function)
|
|
42
|
+
- N+1 query patterns
|
|
43
|
+
|
|
44
|
+
### FRICTION
|
|
45
|
+
Analyze the Happy Path for unnecessary friction:
|
|
46
|
+
- Steps the caller must repeat on every use
|
|
47
|
+
- Configuration that should have a sensible default
|
|
48
|
+
- Error messages that don't tell the user what to do next
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Phase 3 — Self-Correction Loop
|
|
53
|
+
|
|
54
|
+
For each weakness identified in Phase 2:
|
|
55
|
+
|
|
56
|
+
1. State the weakness in one sentence (`file:line` reference if applicable).
|
|
57
|
+
2. Refactor the code to address it.
|
|
58
|
+
3. Re-verify: confirm the original failure point no longer applies.
|
|
59
|
+
|
|
60
|
+
Do not bundle multiple fixes into one step. One weakness → one refactor → one verification.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Phase 4 — Final Report
|
|
65
|
+
|
|
66
|
+
End every implementation with a `[VALIDATION]` section:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
[VALIDATION]
|
|
70
|
+
- Edge cases accounted for: [list]
|
|
71
|
+
- Why this is the best outcome vs simpler alternatives: [one paragraph]
|
|
72
|
+
- Residual risks outside current scope: [list or "none identified"]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Do not omit `[VALIDATION]`. If verbosity is MIN, keep each item to one line. If VERBOSE, expand freely.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memory-first
|
|
3
|
+
description: "Lookup chain enforced before any file read or search: project memory, code graph, grep/glob, Explore sub-agent, targeted read — stop at the first step that answers"
|
|
4
|
+
type: skill
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Memory-First Protocol
|
|
8
|
+
|
|
9
|
+
Follow this lookup chain in strict order before reading any file, running any search, or spawning any tool. Stop at the first step that answers the question.
|
|
10
|
+
|
|
11
|
+
## Chain
|
|
12
|
+
|
|
13
|
+
### 1. Project Memory
|
|
14
|
+
Check `.claude/memory/project.md`.
|
|
15
|
+
|
|
16
|
+
Use the Grep tool to check project.md first:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Grep pattern="<keyword>" path=".claude/memory/project.md"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If Grep returns matches, use that information and stop. If no matches, proceed to step 2.
|
|
23
|
+
|
|
24
|
+
### 2. Graphify Graph
|
|
25
|
+
For structural or relational questions, query the code graph.
|
|
26
|
+
|
|
27
|
+
**Use when asking:**
|
|
28
|
+
- "What calls function X?"
|
|
29
|
+
- "What does module Y depend on?"
|
|
30
|
+
- "Where is interface Z implemented?"
|
|
31
|
+
- "What is the path between component A and B?"
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
graphify query "<your question>"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Skip this step if `graphify` is not installed or the command returns no results. Proceed to step 3.
|
|
38
|
+
|
|
39
|
+
**Do not use for:** literal string patterns, variable names, import statements.
|
|
40
|
+
|
|
41
|
+
### 3. Grep / Glob
|
|
42
|
+
For pattern searches, use the `Grep` or `Glob` tools inline. Never read a full file to find a pattern.
|
|
43
|
+
|
|
44
|
+
### 4. Targeted Read
|
|
45
|
+
Last resort. Only when steps 1–3 cannot answer.
|
|
46
|
+
- Always specify `offset` and `limit`.
|
|
47
|
+
- Max 150 lines per call.
|
|
48
|
+
- Know approximately which lines to read before calling.
|
|
49
|
+
|
|
50
|
+
The `pre-tool-use` hook blocks `Read` calls on files >150 lines with no explicit `limit`. If blocked, return to step 1.
|