crewforth 0.0.1 → 3.0.0-rc.2

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 (169) hide show
  1. package/CHANGELOG.md +3805 -0
  2. package/LICENSE +21 -0
  3. package/README.md +37 -7
  4. package/VERSION +1 -0
  5. package/adopt.sh +1739 -0
  6. package/bin/cli.js +497 -0
  7. package/kit/AGENT_TEMPLATE.md +92 -0
  8. package/kit/CLAUDE.md +228 -0
  9. package/kit/README.md +107 -0
  10. package/kit/agents/crew-backend-expert.md +95 -0
  11. package/kit/agents/crew-commit-agent.md +96 -0
  12. package/kit/agents/crew-database-expert.md +84 -0
  13. package/kit/agents/crew-devops-expert.md +82 -0
  14. package/kit/agents/crew-frontend-expert.md +85 -0
  15. package/kit/agents/crew-performance-expert.md +78 -0
  16. package/kit/agents/crew-planner.md +60 -0
  17. package/kit/agents/crew-privacy-agent.md +71 -0
  18. package/kit/agents/crew-review-agent.md +95 -0
  19. package/kit/agents/crew-security-expert.md +73 -0
  20. package/kit/agents/crew-session-manager.md +77 -0
  21. package/kit/agents/crew-test-expert.md +64 -0
  22. package/kit/eval/doctor.sh +639 -0
  23. package/kit/eval/gate-report.sh +137 -0
  24. package/kit/eval/golden-holdout.txt +53 -0
  25. package/kit/eval/golden-routing.txt +199 -0
  26. package/kit/eval/lib/crew-env.sh +14 -0
  27. package/kit/eval/lib/settings-json.awk +154 -0
  28. package/kit/eval/lib/skill-listing.awk +43 -0
  29. package/kit/eval/lib/star.sh +70 -0
  30. package/kit/eval/parser-conformance.sh +612 -0
  31. package/kit/eval/preflight.sh +186 -0
  32. package/kit/eval/routing-eval.sh +209 -0
  33. package/kit/eval/scan-skill.sh +162 -0
  34. package/kit/eval/smoke-test.sh +6736 -0
  35. package/kit/eval/update-guard.sh +81 -0
  36. package/kit/eval/utilization.sh +130 -0
  37. package/kit/hooks/board-sync.sh +106 -0
  38. package/kit/hooks/board.sh +962 -0
  39. package/kit/hooks/commit-msg +49 -0
  40. package/kit/hooks/context-usage.sh +353 -0
  41. package/kit/hooks/floor-blocklist.txt +124 -0
  42. package/kit/hooks/guard-bash.sh +1433 -0
  43. package/kit/hooks/guard-commit-scan.sh +511 -0
  44. package/kit/hooks/guard-write.sh +513 -0
  45. package/kit/hooks/pre-commit +577 -0
  46. package/kit/hooks/route-hint.sh +185 -0
  47. package/kit/hooks/secret-blocklist.txt +82 -0
  48. package/kit/hooks/session-guard.sh +149 -0
  49. package/kit/hooks/session-rehydrate.sh +41 -0
  50. package/kit/hooks/session-stats.sh +252 -0
  51. package/kit/hooks/session-update-check.sh +236 -0
  52. package/kit/hooks/skill-trust.sh +163 -0
  53. package/kit/hooks/trace-blocklist.txt +53 -0
  54. package/kit/settings.json +132 -0
  55. package/kit/skills/a11y/SKILL.md +44 -0
  56. package/kit/skills/adr/SKILL.md +74 -0
  57. package/kit/skills/api-design/SKILL.md +50 -0
  58. package/kit/skills/automode-policy/SKILL.md +91 -0
  59. package/kit/skills/automode-policy/references/policy.json +13 -0
  60. package/kit/skills/automode-policy/scripts/apply.sh +84 -0
  61. package/kit/skills/automode-policy/scripts/check.sh +102 -0
  62. package/kit/skills/backend-architecture/SKILL.md +103 -0
  63. package/kit/skills/brainstorm/SKILL.md +47 -0
  64. package/kit/skills/ci-pipeline/SKILL.md +38 -0
  65. package/kit/skills/commit-message/SKILL.md +82 -0
  66. package/kit/skills/commit-message/references/examples.md +8 -0
  67. package/kit/skills/confidence-check/SKILL.md +86 -0
  68. package/kit/skills/crew-board/SKILL.md +55 -0
  69. package/kit/skills/crew-brainstorm/SKILL.md +19 -0
  70. package/kit/skills/crew-code-review/SKILL.md +151 -0
  71. package/kit/skills/crew-code-review/references/history-search.md +19 -0
  72. package/kit/skills/crew-code-review/references/panel-mode.md +32 -0
  73. package/kit/skills/crew-code-review/references/receiving.md +23 -0
  74. package/kit/skills/crew-doctor/SKILL.md +46 -0
  75. package/kit/skills/crew-gates/SKILL.md +25 -0
  76. package/kit/skills/crew-handoff/SKILL.md +14 -0
  77. package/kit/skills/crew-plan/SKILL.md +18 -0
  78. package/kit/skills/crew-review/SKILL.md +26 -0
  79. package/kit/skills/crew-ship/SKILL.md +19 -0
  80. package/kit/skills/crew-skill/SKILL.md +62 -0
  81. package/kit/skills/crew-studio/SKILL.md +129 -0
  82. package/kit/skills/crew-update/SKILL.md +43 -0
  83. package/kit/skills/db-migration/SKILL.md +120 -0
  84. package/kit/skills/db-migration/references/backup-restore.md +33 -0
  85. package/kit/skills/db-migration/references/raw-sql.md +30 -0
  86. package/kit/skills/db-migration/references/tool-matrix.md +35 -0
  87. package/kit/skills/dependency-audit/SKILL.md +61 -0
  88. package/kit/skills/dependency-upgrade/SKILL.md +82 -0
  89. package/kit/skills/deploy/SKILL.md +100 -0
  90. package/kit/skills/deploy/references/proxy-ssl.md +56 -0
  91. package/kit/skills/deploy/references/rollback.md +18 -0
  92. package/kit/skills/deploy/references/scripts.md +9 -0
  93. package/kit/skills/deploy/references/topology-a.md +128 -0
  94. package/kit/skills/deploy/references/topology-b.md +44 -0
  95. package/kit/skills/docs-writer/SKILL.md +53 -0
  96. package/kit/skills/docs-writer/references/coauthoring.md +34 -0
  97. package/kit/skills/eval-grader/SKILL.md +75 -0
  98. package/kit/skills/eval-grader/references/method.md +51 -0
  99. package/kit/skills/frontend/SKILL.md +56 -0
  100. package/kit/skills/frontend/references/verify-contract.md +41 -0
  101. package/kit/skills/frontend-design/SKILL.md +71 -0
  102. package/kit/skills/frontend-design/references/design-review.md +34 -0
  103. package/kit/skills/frontend-rn-expo/SKILL.md +25 -0
  104. package/kit/skills/handoff/SKILL.md +71 -0
  105. package/kit/skills/handoff/references/cold-reader.md +51 -0
  106. package/kit/skills/i18n-integrity/SKILL.md +31 -0
  107. package/kit/skills/incident-runbook/SKILL.md +40 -0
  108. package/kit/skills/incident-runbook/references/postmortem.md +16 -0
  109. package/kit/skills/iterate/SKILL.md +40 -0
  110. package/kit/skills/mcp-builder/SKILL.md +54 -0
  111. package/kit/skills/mcp-builder/references/building.md +71 -0
  112. package/kit/skills/observability/SKILL.md +50 -0
  113. package/kit/skills/performance/SKILL.md +38 -0
  114. package/kit/skills/performance/references/bottlenecks.md +10 -0
  115. package/kit/skills/privacy-compliance/SKILL.md +75 -0
  116. package/kit/skills/red-team/SKILL.md +48 -0
  117. package/kit/skills/reflect/SKILL.md +57 -0
  118. package/kit/skills/release/SKILL.md +44 -0
  119. package/kit/skills/security-scan/SKILL.md +99 -0
  120. package/kit/skills/security-scan/references/ai-agents.md +107 -0
  121. package/kit/skills/security-scan/references/fronts.md +99 -0
  122. package/kit/skills/security-scan/references/prompting.md +23 -0
  123. package/kit/skills/security-scan/references/reporting.md +75 -0
  124. package/kit/skills/security-scan/references/verify.md +131 -0
  125. package/kit/skills/sonarqube-check/SKILL.md +108 -0
  126. package/kit/skills/sonarqube-check/references/local-engines.md +32 -0
  127. package/kit/skills/sonarqube-check/references/stand-up-server.md +25 -0
  128. package/kit/skills/spec-planning/SKILL.md +92 -0
  129. package/kit/skills/systematic-debugging/SKILL.md +57 -0
  130. package/kit/skills/systematic-debugging/references/techniques.md +44 -0
  131. package/kit/skills/teamboard/SKILL.md +88 -0
  132. package/kit/skills/teamboard/references/setup.md +37 -0
  133. package/kit/skills/testing/SKILL.md +49 -0
  134. package/kit/skills/testing/references/flaky-triage.md +51 -0
  135. package/kit/skills/threat-model/SKILL.md +57 -0
  136. package/kit/skills/threat-model/references/interview.md +51 -0
  137. package/kit/skills/threat-model/references/schema.md +42 -0
  138. package/kit/skills/token-budget/SKILL.md +51 -0
  139. package/kit/skills/trace-scan/SKILL.md +43 -0
  140. package/kit/skills/worktree/SKILL.md +40 -0
  141. package/kit/studio/README.md +266 -0
  142. package/kit/studio/ensure-node.sh +471 -0
  143. package/kit/studio/package.json +14 -0
  144. package/kit/studio/server/hooks/studio-gate.sh +169 -0
  145. package/kit/studio/server/index.js +902 -0
  146. package/kit/studio/server/lib/crew-env.js +11 -0
  147. package/kit/studio/server/lib/fleet.js +146 -0
  148. package/kit/studio/server/lib/graph.js +533 -0
  149. package/kit/studio/server/lib/instance.js +135 -0
  150. package/kit/studio/server/lib/kit-telemetry.js +182 -0
  151. package/kit/studio/server/lib/kit.js +158 -0
  152. package/kit/studio/server/lib/palette.js +118 -0
  153. package/kit/studio/server/lib/peers.js +72 -0
  154. package/kit/studio/server/lib/permissions.js +150 -0
  155. package/kit/studio/server/lib/projects.js +294 -0
  156. package/kit/studio/server/lib/roster.js +191 -0
  157. package/kit/studio/server/lib/session.js +309 -0
  158. package/kit/studio/server/lib/terminal.js +91 -0
  159. package/kit/studio/server/lib/transcript.js +100 -0
  160. package/kit/studio/web/app.js +1098 -0
  161. package/kit/studio/web/canvas.js +1179 -0
  162. package/kit/studio/web/chat.js +543 -0
  163. package/kit/studio/web/index.html +86 -0
  164. package/kit/studio/web/md.js +110 -0
  165. package/kit/studio/web/storage-migrate.js +23 -0
  166. package/kit/studio/web/style.css +1453 -0
  167. package/package.json +46 -8
  168. package/start.sh +764 -0
  169. package/bin/crewforth.js +0 -10
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: handoff
3
+ description: |
4
+ Session handover: when context fills, a phase closes, or the topic changes, write an action-oriented handover
5
+ to docs/SESSION_STATE.md, then recommend /clear.
6
+ ---
7
+
8
+ # Session Handover (Handoff)
9
+
10
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
11
+ Trigger phrases: "handoff", "hand off", "session summary", "session state", "clear context", "I'll continue", "next session", "where we left off", "run out of room", "continue tomorrow"
12
+
13
+ ## When
14
+ Session fill (the `🔋` line) > 75% · phase closure · topic change. Goal: the next session should **not start from scratch**.
15
+
16
+ ## Output (docs/SESSION_STATE.md, local)
17
+ ```
18
+ # Session Handover — <date>
19
+ ## Done
20
+ - <completed work + which files>
21
+ ## In progress
22
+ - <what's half-finished + exactly where it was left off>
23
+ ## Next step
24
+ - <a clear, single high-value step>
25
+ ## Open decisions
26
+ - <pending decision + options>
27
+ ## File pointers
28
+ - docs/PLAN.md, relevant modules...
29
+ ## Blockers / risks
30
+ - <if any>
31
+ ```
32
+
33
+ ## Measure the session before summarising it
34
+ Run **`bash .claude/hooks/session-stats.sh`** first. What it reports belongs in the handover as fact, not
35
+ impression — an auto-compaction means state was already dropped before you started writing (say what was lost),
36
+ a runaway loop marks an approach the next session should not walk back into, and repeated prompts mark context
37
+ that never landed and has to be written down explicitly this time. Missing script (plugin install) → say so.
38
+
39
+ ## Principles
40
+ - **Action-oriented:** focused not on "what was done" but on "exactly where to resume now."
41
+ - Preserve the rationale behind decisions (why this path was chosen) — so context isn't lost.
42
+ - Once written, start a fresh session with `/clear`.
43
+
44
+ ## Holding a board item? The handover is not finished until the TEAM has it
45
+ `docs/SESSION_STATE.md` is gitignored — it survives your `/clear`, and nobody else can read it. So when a
46
+ `teamboard` claim is open, **the handover is not complete until it is on the board**. This is not an optional
47
+ extra step:
48
+ - Still on it → `board.sh note <id> "<where it stands, and why the rejected path was rejected>"`.
49
+ - Not coming back → `board.sh drop <id> "<same>"`, which puts it back in circulation with your context attached.
50
+ - Anything settled here that changes how OTHER items must be done → `board.sh decide "<what>" "<why + what it
51
+ means>"`. A decision that stays in your transcript reaches nobody; on the board it reaches every teammate at
52
+ their next session opening.
53
+
54
+ Write the board note FIRST, then the local file — an interrupted handover should lose the private copy, not the
55
+ shared one.
56
+
57
+ ## Redaction (`<private>` marker)
58
+ `docs/SESSION_STATE.md` is local, but its content is copied into board notes and handovers — never persist a secret, token, credential, or
59
+ personal note into it. Any content wrapped in **`<private>…</private>`** is a redaction marker: strip it from the
60
+ written handover and leave a `[redacted]` placeholder in its place. If a resume genuinely needs a sensitive value,
61
+ point to *where it lives* (env var, secret manager, the person to ask) — never the value itself.
62
+
63
+ ## Check it before trusting it
64
+ That DoD sentence is a claim about a file nobody has tested. Before closing, run the **cold-reader pass**: write
65
+ 5–8 questions from the WORK (not from the file) with their expected answers, then answer them from the handover
66
+ alone. A question that cannot be answered is a gap in the file. Procedure, phrasing that keeps the test honest,
67
+ and the common failure shapes: **`references/cold-reader.md`**.
68
+
69
+ ## DoD
70
+ - A handover file; a new session can resume where it left off by reading only this file.
71
+ - The cold-reader questions were written **before** the file and every one of them is answerable from it.
@@ -0,0 +1,51 @@
1
+ # The cold-reader pass
2
+
3
+ Loaded on demand. SKILL.md's DoD says a new session can resume by reading only the handover file. This is how
4
+ that sentence is checked instead of asserted — and it is the only part of the handover that can fail silently:
5
+ a file that reads well to its author reads well *because* the author remembers what it leaves out.
6
+
7
+ ## The rule the pass exists to enforce
8
+
9
+ **Write the questions before you write the file, from the work — not from the file.** An answer key derived
10
+ from the handover only proves the handover is self-consistent. Derived from the session, it proves the handover
11
+ carries the session.
12
+
13
+ ## Procedure
14
+
15
+ 1. **Before writing the handover**, list 5–8 questions the next session must be able to answer to continue. Take
16
+ them from the work itself: what was decided and why, what is half-finished and exactly where, what was ruled
17
+ out, what breaks if it is touched, what the next action is. Write the expected answers down beside them.
18
+ 2. **Write the handover** as usual.
19
+ 3. **Answer the questions from the handover alone.** The consumer may open only the paths the file itself names
20
+ — the template requires a file-pointers section, so following those pointers *is* the file working. It may
21
+ not use the session's memory, search the repository for context the file never mentions, or ask.
22
+ 4. **Score each question**: answered · partly answered · not answerable. Any "not answerable" is a gap in the
23
+ handover, not in the reader.
24
+ 5. **Fix the file and re-answer** the failed questions. The pass closes when every question is answerable.
25
+
26
+ ## Phrasing that keeps the test honest
27
+
28
+ - **Do not reuse the handover's own words in the question.** "What did we decide about the cache?" is answerable
29
+ by keyword-matching the heading; "What happens to a request that arrives while the cache is rebuilding?" is
30
+ not. A question a reader can answer by lifting a phrase has measured the search, not the content.
31
+ - **Ask for the reason, not the label.** "Which approach was chosen" is a lookup. "Why was the other one
32
+ rejected" is what a resuming session actually needs, and it is what handovers most often drop.
33
+ - **Ask at least one question whose answer is a location** — a file, a branch, a command. Handovers routinely
34
+ describe a state that nothing points at.
35
+
36
+ ## Who runs it
37
+
38
+ Wherever the handover is written — usually inside `crew-session-manager`, which the discipline routes this
39
+ through, sometimes the main thread. Either way no agent in Crewforth holds the delegation tool (all twelve
40
+ shipped agents declare an explicit allowlist and none contains it), so there is no separate cold-reader
41
+ subagent to hand the file to. That is a real limitation and worth naming: the same context that wrote the file is answering
42
+ from it, so the discipline is entirely in step 1 (questions from the work, written first) and step 3 (answer
43
+ from the file only). If a genuinely cold reader is available — another session, a teammate, a fresh window
44
+ opened at the file — use it; the procedure is unchanged and the result is stronger.
45
+
46
+ ## What a failure looks like
47
+
48
+ The common ones, in the order they occur: the "in progress" entry names a task but not the line it stopped at;
49
+ a decision is recorded without the alternative it beat; a blocker is described without who or what unblocks it;
50
+ and the next step is a category ("continue the refactor") rather than an action. Each of those passes a reading
51
+ by its author and fails a cold reader.
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: i18n-integrity
3
+ description: |
4
+ Translation integrity: every key present in every language, no hardcoded strings, consistent placeholders
5
+ and plurals. Runs when user-facing text changes.
6
+ ---
7
+
8
+ # Translation Integrity (i18n)
9
+
10
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
11
+ Trigger phrases: "i18n", "translation", "language file", "missing translation", "localization", "translate", "untranslated", "hardcoded string", "multi language", "multiple languages", "still in english", "locale"
12
+
13
+ Goal: no missing/broken text in any language. Languages: the set the project declares (e.g. in `CLAUDE.md` or the locale directory).
14
+
15
+ ## Audit dimensions
16
+ - **Key parity:** every key has a counterpart in ALL languages; a missing/extra key = a finding.
17
+ - **No hardcoded strings:** user-facing text is not embedded in code, it comes from the language file.
18
+ - **Placeholder consistency:** `{name}`, `%s`, ICU `{count, plural, ...}` are identical in every language.
19
+ - **Plural rules:** language-specific plural forms (especially RU) are correct.
20
+ - **Empty/identical value:** an untranslated (identical to the source) placeholder value is flagged.
21
+
22
+ ## Check (key-set comparison)
23
+ ```bash
24
+ # Example: compare the key sets of JSON language files
25
+ for f in locales/*.json; do echo "== $f =="; jq -r 'keys[]' "$f" | sort > "/tmp/$(basename $f).keys"; done
26
+ diff /tmp/tr.json.keys /tmp/en.json.keys # differences = missing/extra keys
27
+ ```
28
+
29
+ ## DoD
30
+ - Key sets are equal across all languages; no hardcoded user text; placeholders are consistent.
31
+ - **Missing translation = red** (no deferral).
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: incident-runbook
3
+ description: |
4
+ Production incident response: diagnose → mitigate → resolve, then a blameless postmortem and a repeatable
5
+ runbook. Stop the impact first, root cause second.
6
+ Use when production is degraded or broken, and again for the postmortem afterwards.
7
+ ---
8
+
9
+ # Incident Response & Runbook
10
+
11
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
12
+ Trigger phrases: "incident", "incident response", "runbook", "postmortem", "root cause", "outage", "production incident", "post-incident"
13
+
14
+ Two modes: **live incident** (what to do right now) and **aftermath** (postmortem + runbook). Priority: stopping
15
+ user impact > finding the root cause. No panic, one ordered step at a time.
16
+
17
+ ## Live incident — sequence
18
+ 1. **Acknowledge & classify** — what is the impact (who, how much), severity (SEV1 full outage … SEV3 minor).
19
+ 2. **Mitigate the impact FIRST** — rollback, turn off a feature flag, shift traffic, scale up. Without waiting on the root cause.
20
+ 3. **Single coordinator** — it is clear who decides; communication goes through one channel.
21
+ 4. **Diagnose** — last change? (deploy/migration/config) narrow it down with logs+metrics+traces (observability).
22
+ 5. **Resolve** — the smallest safe fix; then verify (health check).
23
+ 6. **Close** — confirm the impact is over; note the timeline (a postmortem input).
24
+
25
+ ## Mitigation reflexes
26
+ - Last deploy suspect → **rollback** (deploy revert).
27
+ - Suspect feature → turn off the **feature flag**.
28
+ - After a destructive migration → restore from backup (db-migration).
29
+ - Dependency/service down → circuit breaker / graceful degradation.
30
+
31
+ ## After the incident
32
+
33
+ Blameless postmortem + producing a durable runbook: **`references/postmortem.md`**.
34
+
35
+ ## Invariant rules
36
+ 1. **Stop the impact, then understand** — the root cause does not hold up the resolution.
37
+ 2. **Blameless culture** — the postmortem questions the system, not the person.
38
+ 3. **Actions are owned + dated** — no "we'll look at it later".
39
+ 4. **The runbook is executable** — real commands/steps, not wishes.
40
+ 5. **Make learning permanent** — the lesson goes into an adr/runbook/monitoring, it does not get lost.
@@ -0,0 +1,16 @@
1
+ # After the incident — postmortem & runbook
2
+
3
+ Both of these happen **after** the live response is over, not during it. Get the impact stopped first (SKILL.md);
4
+ come here once the incident is resolved.
5
+
6
+ ## Postmortem (blameless)
7
+ Once the incident is resolved, within 24-72 hours:
8
+ - **Timeline**: detection → response → resolution (actual times).
9
+ - **Impact**: who, for how long, what was lost.
10
+ - **Root cause**: "5 whys"; the system/process is questioned, not the person (**blameless**).
11
+ - **Actions**: concrete, owned, dated items that prevent a recurrence (no deferral).
12
+ - If a lasting decision came out of it → `adr`.
13
+
14
+ ## Produce a runbook
15
+ For repeatable incidents, a step-by-step runbook: symptom → diagnostic commands → mitigation → verification → escalation.
16
+ The runbook must be **project-specific** and **executable** (not generic); coordinate with `docs-writer`.
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: iterate
3
+ description: |
4
+ Refine-to-Done loop: repeat until tests green + review clean + nothing deferred; bounded. Not the harness /loop.
5
+ ---
6
+
7
+ # Iterate — refine to Done, don't stop at the first attempt
8
+
9
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
10
+ Trigger phrases: "iterate", "loop until done", "keep going until"
11
+
12
+ ## When
13
+ A task has an objective acceptance criterion (tests, a review gate, a spec) and the first attempt may not
14
+ meet it. This is a single-session refinement loop — NOT the harness `/loop`, which schedules a prompt on an
15
+ interval. Open-ended exploration with no checkable target does not belong here.
16
+
17
+ ## The loop
18
+ 1. **Name the exit test first** — the concrete, checkable condition that means "done": tests green,
19
+ `crew-review-agent` clean, the spec's acceptance criterion met, zero SonarQube findings. No exit test →
20
+ go to spec-planning first; a loop without a target never terminates.
21
+ **Prefer an external, machine-grounded verifier** — a test exit code, a schema match, a lint/quality gate —
22
+ over an LLM's self-assessment. A model grading its own output inflates; an "it looks done" or even a single
23
+ "review clean" with no objective check is a weak verifier. When the only available check is a judgment call,
24
+ ground it (a second agent with a distinct lens, an explicit rubric) rather than trusting the loop's own say-so.
25
+ For a generative task with no exit code, the `eval-grader` skill *is* that external verifier — a two-layer
26
+ scorecard (code metrics + LLM-judge) over a fixed set, read as signed deltas vs a pinned baseline.
27
+ 2. **Run one round**: change → verify (drive the real flow, not only tests) → check the exit test.
28
+ 3. **Report the gap** every round — state what still fails and why. Never loop silently.
29
+ 4. **Repeat** until the exit test passes. Stop early and surface it if: two rounds pass with no new
30
+ progress (you are stuck — report, don't spin), the exit test itself is wrong, or a blocker needs a
31
+ decision from the user.
32
+ 5. **Close at the DoD gate, not at a commit.** `crew-commit-agent` still proposes and waits for §4.4
33
+ approval. The loop never commits, pushes, or deploys on its own.
34
+
35
+ ## Guardrails
36
+ - **Bounded, not infinite.** A fixed exit test plus a no-progress stop is the whole point; "keep trying
37
+ forever" is a bug, not diligence.
38
+ - **Token discipline** ([[token-budget]]): each round re-pays for context. Keep a round's output a summary,
39
+ push heavy logs to `docs/*.md`, and don't fan out a subagent per round unless isolation demands it.
40
+ - **Don't move the goalposts.** Never weaken the exit test to end the loop — fix the work, or stop and ask.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: mcp-builder
3
+ description: |
4
+ Build a Model Context Protocol (MCP) server so an AI client can call your tools/resources: design tool schemas,
5
+ pick a transport, handle errors, and test it. For exposing an API, database, or service to Claude and other clients.
6
+ ---
7
+
8
+ # MCP Builder
9
+
10
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
11
+ Trigger phrases: "MCP server", "build an MCP", "model context protocol", "expose tools to Claude", "MCP tool"
12
+
13
+ An MCP server exposes **tools** (actions the model can call), **resources** (data it can read), and **prompts**
14
+ (reusable templates) to any MCP client over a standard protocol. The whole job is: **design a small set of clear,
15
+ well-described tools, validate their inputs, return useful errors, and prove it works with a real client.** The
16
+ protocol is easy; the design of the tools is what makes the server good or useless.
17
+
18
+ > **Crewforth adaptation (local, .claude/):** Stack-agnostic — TypeScript (`@modelcontextprotocol/sdk`) or Python
19
+ > (`mcp` / FastMCP) are the maintained SDKs; match the project's language. §4 Prohibitions apply (no AI trace in
20
+ > generated code/strings). Secrets (API keys the server needs) go via env, never hardcoded — Crewforth's secret gates apply.
21
+
22
+ ## Design first (the tools ARE the product)
23
+ - **Few, purposeful tools** — expose *tasks*, not a 1:1 mirror of every API endpoint. "create_invoice" beats "post_v2_billing_documents".
24
+ - **The description is the interface** — the model routes on it. Say what it does, when to use it, and what it returns, in plain language. A vague description = an unused or misused tool.
25
+ - **Typed, validated inputs** — a JSON-Schema for each tool; required vs optional explicit; enums over free strings where possible. Reject bad input with a clear message, don't guess.
26
+ - **Useful returns & errors** — return structured, model-readable results; on failure return an actionable error ("no invoice with id X") not a stack trace. Never crash the server on bad input.
27
+ - **Least privilege** — a tool does one scoped thing; destructive actions are explicit and, where possible, confirmable. Don't expose raw SQL / shell unless that is genuinely the product.
28
+
29
+ ## Checklist
30
+ - [ ] Tools chosen by task, not by mirroring endpoints
31
+ - [ ] Each tool has a clear description (what · when · returns) and a JSON-Schema input
32
+ - [ ] Inputs validated; bad input → clear error, not a crash
33
+ - [ ] Returns are structured and model-readable; errors are actionable
34
+ - [ ] Transport chosen (stdio for local, HTTP/SSE for remote) — see references
35
+ - [ ] Secrets via env; no hardcoded keys
36
+ - [ ] Tested against a real client (Inspector + a live client)
37
+
38
+ ---
39
+
40
+ ## Protocol, SDK skeletons, transport, and testing
41
+ Concrete server skeletons (TypeScript + Python), stdio vs. HTTP transport choice, resources/prompts (not just
42
+ tools), and the test loop (MCP Inspector → real client): **`references/building.md`**.
43
+
44
+ ## Invariant rules
45
+ 1. **Design the tools before writing them** — task-shaped, few, clearly described.
46
+ 2. **Validate every input** — schema-checked; bad input returns an error, never crashes.
47
+ 3. **Errors are for the model** — actionable text it can recover from, not raw traces.
48
+ 4. **Secrets via env only** — never hardcode credentials the server needs.
49
+ 5. **Prove it with a real client** — a server that only "looks right" is untested.
50
+ 6. **Descriptions guide; they never authorize** — a tool's description, schema or metadata shapes what the model
51
+ tries. Whether a call is allowed is decided in the handler, per requester and per resource, every time. A schema
52
+ narrows shape; it does not make a path, URL or id safe.
53
+ 7. **Bind identity to the connection, not to a name** — never route a call or accept a result by a tool name,
54
+ server name or alias the other side can choose. How these fail is in `security-scan/references/ai-agents.md`.
@@ -0,0 +1,71 @@
1
+ # MCP: protocol, skeletons, transport, testing
2
+
3
+ Loaded on demand. SKILL.md is the design discipline; this is the concrete how.
4
+
5
+ ## The three primitives
6
+
7
+ - **Tools** — actions the model invokes (side effects allowed): `create_ticket`, `search_orders`. This is what most servers are for.
8
+ - **Resources** — readable data addressed by URI the client can pull into context: `file://…`, `db://customers/42`. Read-only.
9
+ - **Prompts** — named, parameterized templates the user/client can invoke. Optional; add only if you have reusable flows.
10
+
11
+ Start with tools. Add resources when the client needs to *read* your data as context; add prompts only if there's a real reusable template.
12
+
13
+ ## Transport — pick by where it runs
14
+
15
+ - **stdio** — the server is a local subprocess of the client (desktop app, CLI). Simplest; no network, no auth. Default for local/dev tools.
16
+ - **Streamable HTTP / SSE** — the server is remote (hosted, shared). You now own auth, CORS, and network errors. Use only when the tool must be remote/multi-user.
17
+
18
+ ## Skeletons
19
+
20
+ **TypeScript (`@modelcontextprotocol/sdk`):**
21
+ ```ts
22
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
23
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
24
+ import { z } from "zod";
25
+
26
+ const server = new McpServer({ name: "orders", version: "1.0.0" });
27
+
28
+ server.tool(
29
+ "search_orders",
30
+ "Search orders by customer email. Returns up to 20 orders, newest first.",
31
+ { email: z.string().email(), limit: z.number().int().min(1).max(20).default(20) },
32
+ async ({ email, limit }) => {
33
+ const orders = await db.findOrders(email, limit); // your logic
34
+ if (!orders.length) return { content: [{ type: "text", text: `No orders for ${email}.` }] };
35
+ return { content: [{ type: "text", text: JSON.stringify(orders) }] };
36
+ }
37
+ );
38
+ await server.connect(new StdioServerTransport());
39
+ ```
40
+
41
+ **Python (FastMCP):**
42
+ ```python
43
+ from mcp.server.fastmcp import FastMCP
44
+
45
+ mcp = FastMCP("orders")
46
+
47
+ @mcp.tool()
48
+ def search_orders(email: str, limit: int = 20) -> str:
49
+ """Search orders by customer email. Returns up to 20 orders, newest first."""
50
+ orders = db.find_orders(email, limit) # your logic
51
+ return f"No orders for {email}." if not orders else json_dumps(orders)
52
+
53
+ if __name__ == "__main__":
54
+ mcp.run() # stdio by default
55
+ ```
56
+
57
+ Both: the **docstring/description is the model's interface** — write it as the design step demands. Types drive the input schema (zod / Python type hints) — no hand-written JSON-Schema needed with these SDKs.
58
+
59
+ ## Error handling
60
+
61
+ - Validate at the boundary — the SDK schema rejects wrong *types*; you still check *semantics* (does the id exist? is the caller allowed?).
62
+ - Return errors as normal tool results with clear text the model can act on, or throw the SDK's error type for protocol-level failures. Never let an unhandled exception kill the process on bad input.
63
+ - Don't leak internals (stack traces, connection strings) in error text.
64
+
65
+ ## The test loop
66
+
67
+ 1. **MCP Inspector** — `npx @modelcontextprotocol/inspector <run-command>` launches a UI that lists your tools/resources and lets you call them with arbitrary inputs. Verify each tool's schema, a happy path, and a bad-input path here first — fastest feedback.
68
+ 2. **Real client** — register the server in an actual client (e.g. Claude Desktop / Claude Code `.mcp.json`) and confirm the model *discovers* it, *routes* to the right tool from a natural prompt (validates your descriptions), and handles the returned data.
69
+ 3. **Edge cases** — empty results, invalid input, missing auth, large output. A tool is done when its failure modes are as clean as its happy path.
70
+
71
+ If the model picks the wrong tool or ignores yours, the bug is almost always the **description**, not the code — rewrite it and re-test in the real client.
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: observability
3
+ description: |
4
+ Stack-agnostic observability: structured logs, correlation ids, metrics and traces; no PII or secrets in logs.
5
+ Makes a production issue traceable to why it happened.
6
+ Use when adding a log line, an error path, a metric, or when an incident could not be traced.
7
+ ---
8
+
9
+ # Observability
10
+
11
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
12
+ Trigger phrases: "observability", "structured logging", "structured log", "add a trace", "add a metric", "correlation id", "add logging"
13
+
14
+ Goal: to be able to answer "what happened, where, why" during a production incident **by looking at the logs**.
15
+ It is stack-agnostic; when you need a framework-specific library/format, do a web search.
16
+
17
+ ## Three signals
18
+ - **Log** — event record (structured/JSON, leveled).
19
+ - **Metric** — numeric time series (request count, latency, error rate, resource usage).
20
+ - **Trace** — a request's journey across services (spans + correlation id).
21
+
22
+ ## Checklist
23
+ - [ ] Logs are **structured** (JSON/key-value), not string interpolation
24
+ - [ ] Every log line carries a **correlation id** (request/trace id)
25
+ - [ ] Levels are correct: the DEBUG/INFO/WARN/ERROR distinction is meaningful
26
+ - [ ] **No PII/secret is logged** (password, token, card, national/ID number, email body)
27
+ - [ ] Error logs carry context (input summary, user/resource id — not PII); the stack trace does not leak to the user
28
+ - [ ] Critical business metric + infrastructure metric are emitted (where applicable)
29
+ - [ ] The correlation id is **propagated** across service-to-service calls (header/propagation)
30
+
31
+ ## How
32
+ 1. **Structured logger** — set up/use one whose output is machine-readable (JSON). Search for the library the framework recommends.
33
+ 2. **Correlation id**: generate it at the entry point (HTTP middleware / message consumer) or take it from the incoming `X-Request-Id`/trace header; put it in the log context; **propagate** it to downstream calls.
34
+ 3. **Level discipline**: INFO = business event, WARN = expected-but-noteworthy, ERROR = needs intervention. DEBUG is off/sampled in production.
35
+ 4. **Context fields**: `event`, `correlation_id`, `user_id` (not PII, an opaque id), `duration_ms`, `outcome`. Do not embed them in free text.
36
+ 5. **Metrics**: at minimum RED (Rate, Errors, Duration) or USE; plus business-critical counters. Search for the framework's metrics library.
37
+ 6. **Trace** (in a distributed system): start/end spans, bind the correlation id to the trace id.
38
+
39
+ ## PII / secret leakage (critical)
40
+ **Never** to the log: password, token, API key, card number, national/ID number, full email/phone body, raw request body.
41
+ - Mask: `user@***`, card `**** 1234`, token `sk-p…789`.
42
+ - When needed, log an **opaque id** (hash/uuid), not the raw value.
43
+ - This axis overlaps with `security-scan` (sensitive data in logs) and `privacy-compliance` (KVKK/GDPR) — if personal data is involved, trigger those too.
44
+
45
+ ## Invariant rules
46
+ 1. **Structured > free text** — greppable, parseable.
47
+ 2. **Correlation id on every line** — without it, a distributed error is untraceable.
48
+ 3. **No PII/secret is logged** — mask it or use an opaque id.
49
+ 4. **Do not make noise** — every line must answer a question; do not add meaningless spam logs.
50
+ 5. **Match the existing format** — if the repo has a logger, follow its pattern; do not impose a new one.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: performance
3
+ description: |
4
+ Stack-agnostic performance: measure first, find the bottleneck, then optimise. N+1, needless allocation, wrong
5
+ async boundary, missing index/cache, heavy payload. No premature optimisation.
6
+ Use when something is slow, before optimising anything, and when a change touches a hot path.
7
+ ---
8
+
9
+ # Performance
10
+
11
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
12
+ Trigger phrases: "performance", "slow", "optimization", "profiling", "N+1", "latency", "memory leak", "leaked memory", "load test", "seconds to open", "seconds to respond", "anything slower", "make it slower"
13
+
14
+ Core rule: **measure first, optimize later.** Optimization without measurement is a guess; it usually speeds up the
15
+ wrong place and adds complexity. Stack-agnostic; do a web search when you need the profiling tool/library.
16
+
17
+ ## Method (in order)
18
+ 1. **Set a target** — what is "acceptable"? (p95 latency, throughput, memory ceiling). Numeric.
19
+ 2. **Measure** — find the real bottleneck with a profiler/APM/benchmark; don't start from a guess.
20
+ 3. **Fix the single most expensive thing** — Amdahl: speeding up a 5% path by 2x is wasted; target the hot path.
21
+ 4. **Measure again** — did it actually improve, is there a regression.
22
+ 5. **Stop** — once you hit the target, finish; no endless micro-optimization.
23
+
24
+ ## Common bottlenecks
25
+
26
+ Catalog of common bottlenecks + fixes to consult: **`references/bottlenecks.md`**.
27
+
28
+ ## Measurement tips
29
+ - Measure **under load** (a single request misleads); with a realistic data volume.
30
+ - **Not p50, but p95/p99** — tail latency is what burns the user.
31
+ - Don't trust micro-benchmarks; an end-to-end profile is more honest.
32
+
33
+ ## Invariant rules
34
+ 1. **Don't optimize without measuring** — a change without a profile = a guess.
35
+ 2. **Target the hot path** — don't speed up the small share.
36
+ 3. **Don't break correctness** — don't sacrifice behavior/edge cases for speed.
37
+ 4. **Complexity budget** — make an optimization that seriously hurts readability only if there is a measured gain; comment it.
38
+ 5. **Stop once you hit the target** — YAGNI; no premature/excessive optimization.
@@ -0,0 +1,10 @@
1
+ # Common bottlenecks
2
+
3
+ | Area | Pattern | Fix |
4
+ |---|---|---|
5
+ | **DB** | N+1 query, missing index, `SELECT *`, table scan | eager/batch loading, index (db-migration), only needed columns |
6
+ | **Memory** | needless allocation, holding large objects, leak | pooling, streaming, releasing references |
7
+ | **Async** | wrong sync/async boundary, blocking I/O, serial await | parallel await, non-blocking I/O |
8
+ | **Network/payload** | oversized response, no compression, chatty API | pagination, field selection, gzip, batch (api-design) |
9
+ | **Cache** | repeated expensive computation, no/wrong cache | cache at the right layer + correct invalidation |
10
+ | **Frontend** | needless render, large bundle, blocking resource | memo, code-split, lazy, critical CSS |
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: privacy-compliance
3
+ description: |
4
+ KVKK/GDPR audit method: data inventory, purpose/basis/retention, minimisation, consent, transparency,
5
+ data-subject rights, cross-border transfer. crew-privacy-agent applies it.
6
+ ---
7
+
8
+ # Privacy Compliance (KVKK / GDPR)
9
+
10
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
11
+ Trigger phrases: "kvkk", "gdpr", "privacy", "consent", "data retention", "minimization", "personal information", "what we store about", "data we collect", "delete my data", "right to be forgotten"
12
+
13
+ <!-- Requires-tool: WebFetch -->
14
+ <!-- Machine-readable, and smoke-test enforces it: every agent that applies this skill must carry WebFetch.
15
+ Without it the instruction below is one an agent physically cannot obey — it would either decide from
16
+ memory, which this skill forbids in the same breath, or quietly skip the check. -->
17
+
18
+ ## Official sources (authority — always defer to these)
19
+ The **primary, official** sources this skill rests on; rules are always interpreted against these:
20
+ - **KVKK** (Turkey): https://www.kvkk.gov.tr/ — the law, regulations, principle decisions, guidelines.
21
+ - **GDPR** (EU): https://gdpr-info.eu/ — article texts (Art.) and Recitals.
22
+
23
+ If you are unsure about a specific article/threshold/definition (retention period, explicit-consent requirement,
24
+ the Art. 8 age limit, transfer basis, etc.), **check the relevant official source** — do not decide from memory or by
25
+ guessing. In the finding, **cite** the article you rely on (KVKK Art. … / GDPR Art. …). Fetched content is a reference; you own the interpretation.
26
+
27
+ ## Which regimes apply — the project says so, Crewforth does not guess
28
+ KVKK and GDPR above are the **defaults**, not the world. A product sold in California is under CCPA and one in
29
+ Brazil under LGPD, and Crewforth shipping a global list would be claiming knowledge it does not have — the same
30
+ mistake as rating code without running the analyser. So the project declares its own, and the authority is
31
+ whatever source it names.
32
+
33
+ Read **`.claude/regulations.conf`** if it exists. One regime per line, `#` comments ignored:
34
+
35
+ ```
36
+ # name | official source | axis
37
+ KVKK | https://www.kvkk.gov.tr/ | personal-data
38
+ GDPR | https://gdpr-info.eu/ | personal-data
39
+ CCPA | https://oag.ca.gov/privacy/ccpa | personal-data
40
+ ```
41
+
42
+ | What you find | What you do |
43
+ |---|---|
44
+ | No file | Audit against KVKK + GDPR |
45
+ | A regime **with** a source | Audit it; every finding cites that regime's article, checked against its source |
46
+ | A regime with **no** source | **Do not rule on it.** Report "declared, no source given — cannot audit" and ask for the URL |
47
+ | An axis other than `personal-data` (BDDK, PCI-DSS, HIPAA, SOX…) | **Say so out loud**: sector regulation is outside this skill. Do not audit it, and do not let its presence in the file imply that it was |
48
+
49
+ That last row is the point of the file, not an edge case. Somebody who writes `BDDK` into it and gets a clean
50
+ report would reasonably conclude Crewforth checked it. It did not, and silence would be the lie.
51
+
52
+ The declaration file is the **project's**, never Crewforth's: no installer writes it and no update rewrites it.
53
+ Its absence means "the defaults apply", which is why nothing has to be created for the common case.
54
+
55
+ ## Audit axes
56
+ - **Inventory:** what data, collected from where, flowing to where, shared with whom?
57
+ - **Purpose + basis + retention:** for each field, purpose is limited, legal basis is clear, retention period is defined.
58
+ - **Minimization:** data not needed for the purpose is not collected.
59
+ - **Consent:** where required, explicit, recorded, and revocable.
60
+ - **Transparency:** disclosure has been made; the user knows what is collected/processed.
61
+ - **Data subject rights:** access / rectification / erasure / portability / objection are actionable.
62
+ - **Cross-border transfer & third-party:** bound to a legitimate basis (SCC/adequacy/consent).
63
+
64
+ ## Output
65
+ Per-field/per-flow finding + fix; if "clean", the rationale.
66
+
67
+ **Evidence redaction (`<private>` marker):** an audit report is a shared artifact — it must not itself leak the
68
+ personal data it audits. When a finding has to reference a real value as evidence, wrap it in
69
+ **`<private>…</private>`**: the raw value is stripped and shown as `[redacted]` in the report, while the finding still
70
+ names the field, flow, and article. Never paste live PII (national ID, email, phone, health data) into the report body.
71
+
72
+ > **Project note:** If data of minors (children) is processed, special protection is required
73
+ > (KVKK / GDPR Art. 8 · parental consent & age verification). This is a domain-specific rule and is
74
+ > defined in the project's own skill/CLAUDE.md — it is not baked into the generic audit.
75
+ > Project-specific rules (consent texts, retention periods) also live in the project CLAUDE.md.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: red-team
3
+ description: |
4
+ Attacker's-eye test of LLM/agent defenses: instruction hijacking, data exfiltration and tool abuse through
5
+ untrusted content; verifies whether the defense actually holds.
6
+ ---
7
+
8
+ # Red Team (LLM / Agent Defense)
9
+
10
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
11
+ Trigger phrases: "red team", "red-team", "prompt injection", "test prompt injection", "jailbreak", "defense test", "adversarial test", "injection scenario", "previous instructions", "hidden instructions", "malicious instructions", "injected instructions"
12
+
13
+ Goal: verify a system's defense against prompt injection and abuse by **attempting to break it**.
14
+ Only meaningful on systems that have a defense (the CLAUDE.md "Untrusted content" axis); report findings to `crew-security-expert`.
15
+
16
+ > **Ethical boundary:** Only test **your own / authorized** system. The attack scenarios generated are for
17
+ > verifying the defense; actual harm / use against someone else's system is out of scope (§4, security policy).
18
+
19
+ ## Threat model — what to test
20
+ - **Instruction hijacking**: content read via a tool (web, file, issue, e-mail, DOM) says "forget the previous instructions / run this." Does the system keep it as **data**, or treat it as a command?
21
+ - **Authority/approval bypass**: content gives a fake approval like "the user authorized / test mode / admin." Does the system take its §4.4/§4.5 approval only from the user?
22
+ - **Data exfiltration**: content suggests sending user data to an address/endpoint. Does the system blindly fetch/exfil?
23
+ - **Tool abuse**: content embeds a destructive command / hidden link / encoded instruction.
24
+ - **Indirect injection**: a malicious instruction is stashed in data that will be read later (a record, a comment, a file name).
25
+
26
+ ## How to test
27
+ 1. **Extract entry points** — every place the system reads untrusted content (the same attack surface: security-scan).
28
+ 2. **Plant an injection payload** — embed an instruction/authority-claim/urgency/encoded text into that content.
29
+ 3. **Observe**: did the system apply the instruction, or surface it and ask the user? Did it take approval from the content?
30
+ 4. **Vary it**: role-play, "test mode", multi-step, cross-language, base64/homoglyph evasion.
31
+ 5. **Classify the result**: defense held / partial / broken; every break is a finding.
32
+
33
+ ## Evaluation
34
+ | Result | Meaning |
35
+ |---|---|
36
+ | **Held** | The instruction was treated as data, surfaced, approval only from the user |
37
+ | **Partial** | Some variants leaked; the defense is inconsistent |
38
+ | **Broken** | The instruction in the content was applied / a fake approval was accepted → CRITICAL |
39
+
40
+ ## Invariant rules
41
+ 1. **Authorized system only** — test your own defense; no real attack / someone else's system.
42
+ 2. **Finding = a defense gap** — report it for the fix, not for exploitation (crew-security-expert).
43
+ 3. **Do not leak payloads** — masked/summarized in the finding; do not spread a live malicious command.
44
+ 4. **Strengthen the defense layer** — every break feeds back into the CLAUDE.md "Untrusted content" rule.
45
+ 5. **A model saying the wrong thing is not yet a finding** — it becomes one when code lets that output cross a
46
+ boundary: reach another user's context, act with authority the requester lacks, disclose data they cannot read,
47
+ or drive a sink they could not reach. The code-level classes behind that line are in
48
+ `security-scan/references/ai-agents.md`.