crewforth 0.0.1 → 3.0.0-rc.1

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 (168) hide show
  1. package/CHANGELOG.md +3784 -0
  2. package/LICENSE +21 -0
  3. package/README.md +37 -7
  4. package/VERSION +1 -0
  5. package/adopt.sh +1670 -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 +465 -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/star.sh +70 -0
  29. package/kit/eval/parser-conformance.sh +612 -0
  30. package/kit/eval/preflight.sh +186 -0
  31. package/kit/eval/routing-eval.sh +209 -0
  32. package/kit/eval/scan-skill.sh +162 -0
  33. package/kit/eval/smoke-test.sh +6693 -0
  34. package/kit/eval/update-guard.sh +81 -0
  35. package/kit/eval/utilization.sh +130 -0
  36. package/kit/hooks/board-sync.sh +106 -0
  37. package/kit/hooks/board.sh +962 -0
  38. package/kit/hooks/commit-msg +49 -0
  39. package/kit/hooks/context-usage.sh +353 -0
  40. package/kit/hooks/floor-blocklist.txt +124 -0
  41. package/kit/hooks/guard-bash.sh +1431 -0
  42. package/kit/hooks/guard-commit-scan.sh +511 -0
  43. package/kit/hooks/guard-write.sh +513 -0
  44. package/kit/hooks/pre-commit +577 -0
  45. package/kit/hooks/route-hint.sh +185 -0
  46. package/kit/hooks/secret-blocklist.txt +82 -0
  47. package/kit/hooks/session-guard.sh +149 -0
  48. package/kit/hooks/session-rehydrate.sh +41 -0
  49. package/kit/hooks/session-stats.sh +252 -0
  50. package/kit/hooks/session-update-check.sh +236 -0
  51. package/kit/hooks/skill-trust.sh +150 -0
  52. package/kit/hooks/trace-blocklist.txt +53 -0
  53. package/kit/settings.json +132 -0
  54. package/kit/skills/a11y/SKILL.md +44 -0
  55. package/kit/skills/adr/SKILL.md +74 -0
  56. package/kit/skills/api-design/SKILL.md +50 -0
  57. package/kit/skills/automode-policy/SKILL.md +91 -0
  58. package/kit/skills/automode-policy/references/policy.json +13 -0
  59. package/kit/skills/automode-policy/scripts/apply.sh +84 -0
  60. package/kit/skills/automode-policy/scripts/check.sh +102 -0
  61. package/kit/skills/backend-architecture/SKILL.md +103 -0
  62. package/kit/skills/brainstorm/SKILL.md +47 -0
  63. package/kit/skills/ci-pipeline/SKILL.md +38 -0
  64. package/kit/skills/commit-message/SKILL.md +82 -0
  65. package/kit/skills/commit-message/references/examples.md +8 -0
  66. package/kit/skills/confidence-check/SKILL.md +86 -0
  67. package/kit/skills/crew-board/SKILL.md +55 -0
  68. package/kit/skills/crew-brainstorm/SKILL.md +19 -0
  69. package/kit/skills/crew-code-review/SKILL.md +151 -0
  70. package/kit/skills/crew-code-review/references/history-search.md +19 -0
  71. package/kit/skills/crew-code-review/references/panel-mode.md +32 -0
  72. package/kit/skills/crew-code-review/references/receiving.md +23 -0
  73. package/kit/skills/crew-doctor/SKILL.md +36 -0
  74. package/kit/skills/crew-gates/SKILL.md +25 -0
  75. package/kit/skills/crew-handoff/SKILL.md +14 -0
  76. package/kit/skills/crew-plan/SKILL.md +18 -0
  77. package/kit/skills/crew-review/SKILL.md +23 -0
  78. package/kit/skills/crew-ship/SKILL.md +19 -0
  79. package/kit/skills/crew-skill/SKILL.md +61 -0
  80. package/kit/skills/crew-studio/SKILL.md +129 -0
  81. package/kit/skills/crew-update/SKILL.md +43 -0
  82. package/kit/skills/db-migration/SKILL.md +120 -0
  83. package/kit/skills/db-migration/references/backup-restore.md +33 -0
  84. package/kit/skills/db-migration/references/raw-sql.md +30 -0
  85. package/kit/skills/db-migration/references/tool-matrix.md +35 -0
  86. package/kit/skills/dependency-audit/SKILL.md +61 -0
  87. package/kit/skills/dependency-upgrade/SKILL.md +82 -0
  88. package/kit/skills/deploy/SKILL.md +100 -0
  89. package/kit/skills/deploy/references/proxy-ssl.md +56 -0
  90. package/kit/skills/deploy/references/rollback.md +18 -0
  91. package/kit/skills/deploy/references/scripts.md +9 -0
  92. package/kit/skills/deploy/references/topology-a.md +128 -0
  93. package/kit/skills/deploy/references/topology-b.md +44 -0
  94. package/kit/skills/docs-writer/SKILL.md +53 -0
  95. package/kit/skills/docs-writer/references/coauthoring.md +34 -0
  96. package/kit/skills/eval-grader/SKILL.md +75 -0
  97. package/kit/skills/eval-grader/references/method.md +51 -0
  98. package/kit/skills/frontend/SKILL.md +56 -0
  99. package/kit/skills/frontend/references/verify-contract.md +41 -0
  100. package/kit/skills/frontend-design/SKILL.md +71 -0
  101. package/kit/skills/frontend-design/references/design-review.md +34 -0
  102. package/kit/skills/frontend-rn-expo/SKILL.md +25 -0
  103. package/kit/skills/handoff/SKILL.md +71 -0
  104. package/kit/skills/handoff/references/cold-reader.md +51 -0
  105. package/kit/skills/i18n-integrity/SKILL.md +31 -0
  106. package/kit/skills/incident-runbook/SKILL.md +40 -0
  107. package/kit/skills/incident-runbook/references/postmortem.md +16 -0
  108. package/kit/skills/iterate/SKILL.md +40 -0
  109. package/kit/skills/mcp-builder/SKILL.md +54 -0
  110. package/kit/skills/mcp-builder/references/building.md +71 -0
  111. package/kit/skills/observability/SKILL.md +50 -0
  112. package/kit/skills/performance/SKILL.md +38 -0
  113. package/kit/skills/performance/references/bottlenecks.md +10 -0
  114. package/kit/skills/privacy-compliance/SKILL.md +75 -0
  115. package/kit/skills/red-team/SKILL.md +48 -0
  116. package/kit/skills/reflect/SKILL.md +57 -0
  117. package/kit/skills/release/SKILL.md +44 -0
  118. package/kit/skills/security-scan/SKILL.md +99 -0
  119. package/kit/skills/security-scan/references/ai-agents.md +107 -0
  120. package/kit/skills/security-scan/references/fronts.md +99 -0
  121. package/kit/skills/security-scan/references/prompting.md +23 -0
  122. package/kit/skills/security-scan/references/reporting.md +75 -0
  123. package/kit/skills/security-scan/references/verify.md +131 -0
  124. package/kit/skills/sonarqube-check/SKILL.md +108 -0
  125. package/kit/skills/sonarqube-check/references/local-engines.md +32 -0
  126. package/kit/skills/sonarqube-check/references/stand-up-server.md +25 -0
  127. package/kit/skills/spec-planning/SKILL.md +92 -0
  128. package/kit/skills/systematic-debugging/SKILL.md +57 -0
  129. package/kit/skills/systematic-debugging/references/techniques.md +44 -0
  130. package/kit/skills/teamboard/SKILL.md +88 -0
  131. package/kit/skills/teamboard/references/setup.md +37 -0
  132. package/kit/skills/testing/SKILL.md +49 -0
  133. package/kit/skills/testing/references/flaky-triage.md +51 -0
  134. package/kit/skills/threat-model/SKILL.md +57 -0
  135. package/kit/skills/threat-model/references/interview.md +51 -0
  136. package/kit/skills/threat-model/references/schema.md +42 -0
  137. package/kit/skills/token-budget/SKILL.md +51 -0
  138. package/kit/skills/trace-scan/SKILL.md +43 -0
  139. package/kit/skills/worktree/SKILL.md +40 -0
  140. package/kit/studio/README.md +266 -0
  141. package/kit/studio/ensure-node.sh +471 -0
  142. package/kit/studio/package.json +14 -0
  143. package/kit/studio/server/hooks/studio-gate.sh +169 -0
  144. package/kit/studio/server/index.js +902 -0
  145. package/kit/studio/server/lib/crew-env.js +11 -0
  146. package/kit/studio/server/lib/fleet.js +146 -0
  147. package/kit/studio/server/lib/graph.js +533 -0
  148. package/kit/studio/server/lib/instance.js +135 -0
  149. package/kit/studio/server/lib/kit-telemetry.js +182 -0
  150. package/kit/studio/server/lib/kit.js +158 -0
  151. package/kit/studio/server/lib/palette.js +118 -0
  152. package/kit/studio/server/lib/peers.js +72 -0
  153. package/kit/studio/server/lib/permissions.js +150 -0
  154. package/kit/studio/server/lib/projects.js +294 -0
  155. package/kit/studio/server/lib/roster.js +191 -0
  156. package/kit/studio/server/lib/session.js +309 -0
  157. package/kit/studio/server/lib/terminal.js +91 -0
  158. package/kit/studio/server/lib/transcript.js +100 -0
  159. package/kit/studio/web/app.js +1098 -0
  160. package/kit/studio/web/canvas.js +1179 -0
  161. package/kit/studio/web/chat.js +543 -0
  162. package/kit/studio/web/index.html +86 -0
  163. package/kit/studio/web/md.js +110 -0
  164. package/kit/studio/web/storage-migrate.js +23 -0
  165. package/kit/studio/web/style.css +1453 -0
  166. package/package.json +46 -8
  167. package/start.sh +748 -0
  168. package/bin/crewforth.js +0 -10
@@ -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`.
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: reflect
3
+ description: |
4
+ Retrospective self-audit after nontrivial work: unverified assumptions, skipped items, is-this-the-right-
5
+ approach — findings, not code. The step-back counterpart to iterate's refine-to-done loop.
6
+ ---
7
+
8
+ # Reflect — step back and audit the work, not just the code
9
+
10
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
11
+ Trigger phrases: "reflect", "retro", "retrospective", "what did we miss", "step back", "introspect"
12
+
13
+ ## When
14
+ A nontrivial chunk of work just finished (a feature, a plan, a debugging session) and it's worth a deliberate
15
+ step back **before** committing or moving on. This is the meta-cognitive counterpart to [[iterate]]: iterate
16
+ drives a change *to* its exit test; reflect asks whether the exit test — and the approach behind it — was even
17
+ the right one. Skip it for a one-line, unambiguous change; there's nothing to reflect on.
18
+
19
+ ## Measure first, then remember
20
+ Run **`bash .claude/hooks/session-stats.sh`** before answering anything below, and open the pass with what it
21
+ reports. A retro built only on recall is an interview with the least reliable witness in the room: the model
22
+ reconstructs a tidy story from a context that has already been summarised, and the stretches where it span on a
23
+ failing approach are exactly the ones it remembers least. The script counts what actually happened — prompts,
24
+ tool calls, failing loops, near-duplicate prompts, interrupts, auto-compactions.
25
+
26
+ Treat each ⚠️ as a **question to answer in the pass**, not a verdict: a runaway loop asks *what assumption kept
27
+ failing*; a repeated prompt asks *what context never landed*; an interrupt asks *where intent diverged*; an auto
28
+ compaction asks *what state was silently dropped*. If the numbers and your recollection disagree, the numbers are
29
+ the record. If the script is missing (a plugin install has no `.claude/hooks/`), say the retro is recall-based —
30
+ do not present recall as measurement.
31
+
32
+ ## The pass
33
+ Ask each question honestly and write the answer, not a reassurance:
34
+ 1. **Unverified assumptions** — what did I take for granted that I never checked? Name each one and whether it
35
+ was actually confirmed (read the code / ran the flow) or just assumed.
36
+ 2. **What got skipped** — an edge case, an error path, a test, a doc update, a security/privacy angle. What was
37
+ silently dropped, and was that a conscious trade-off or an oversight?
38
+ 3. **Right approach?** — with hindsight, is this the direction we'd still pick? Did scope creep in? Is there a
39
+ simpler path we walked past ([[code-review]] altitude: could 200 lines be 50)?
40
+ 4. **Evidence gap** — which claims of "done" / "works" rest on having *observed* behavior vs. on inference?
41
+ An unobserved "it works" is a finding (see [[iterate]] / verify: drive the real flow).
42
+ 5. **What I'd tell the next session** — the one thing a fresh context most needs to know (feeds [[handoff]]).
43
+
44
+ ## Guardrails
45
+ - **Findings, not code.** Reflect surfaces gaps; the relevant specialist fixes them (a found gap re-enters
46
+ [[iterate]] or the author agent). It changes nothing itself.
47
+ - **Honest, not performative.** A retro that only confirms good work is a failed retro. If nothing is found,
48
+ say specifically *why* you're confident (what was verified), don't just assert it.
49
+ - **Bounded.** One pass, concrete findings, then act or close — not an open rumination loop.
50
+ - **Token discipline** ([[token-budget]]): a short ranked findings list to the main thread; detail to a file.
51
+
52
+ ## DoD (this skill's contribution)
53
+ - `session-stats.sh` was run and every ⚠️ it raised is answered — or its absence is stated.
54
+ - Assumptions are labeled verified vs. assumed; unverified ones are flagged, not buried.
55
+ - Skipped items and any scope creep are named explicitly.
56
+ - Every "done/works" claim is traced to observed evidence or marked as inference.
57
+ - Findings are actionable (each maps to a fix, a follow-up, or an accepted trade-off).
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: release
3
+ description: |
4
+ Versioning and CHANGELOG: SemVer mapped from Conventional Commits, Keep a Changelog format, tagging,
5
+ pre-release gates.
6
+ Use when cutting a version: bumping, writing the CHANGELOG entry, or tagging.
7
+ ---
8
+
9
+ # Release & CHANGELOG
10
+
11
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
12
+ Trigger phrases: "release", "cut a release", "changelog", "version bump", "bump the version", "new version", "tag", "semver"
13
+
14
+ ## SemVer mapping (derive from Conventional Commits)
15
+ - `fix:` → **PATCH** (x.y.Z)
16
+ - `feat:` → **MINOR** (x.Y.0)
17
+ - `BREAKING CHANGE:` / `feat!:` → **MAJOR** (X.0.0)
18
+
19
+ ## CHANGELOG (Keep a Changelog)
20
+ Headings: **Added · Changed · Fixed · Removed · Security · Deprecated**.
21
+ Every version is dated; the `Unreleased` section can be auto-populated from commits.
22
+
23
+ ## Pre-release gates (all must pass)
24
+ - [ ] Tests green + `sonarqube-check` PASSED
25
+ - [ ] `dependency-audit` clean (0 HIGH/CRITICAL)
26
+ - [ ] CHANGELOG up to date
27
+ - [ ] Version number conforms to SemVer
28
+ - [ ] **The release commit is a diff too (§4.6).** A `chore(release)` bump, a CHANGELOG-only edit and a docs-site
29
+ version touch each stage a diff, and §4.6 exempts nothing by size — `crew-review-agent` runs over them like
30
+ any other. A version that disagrees with the tag, a CHANGELOG entry naming the wrong one, a generated
31
+ manifest edited by hand: that is what this review is for, and all three have shipped before.
32
+ - [ ] **Every distribution channel has a documented way to GET this version.** Publishing and reaching users are
33
+ different events. A channel whose consumers pin at install time — an editor extension, a plugin, a vendored
34
+ copy — leaves them on the version they installed until they ask for a new one, so a security fix ships and
35
+ does not arrive. For each channel name the upgrade command in the README, and say plainly where it is not
36
+ automatic.
37
+
38
+ ## Tagging
39
+ ```bash
40
+ git tag -a vX.Y.Z -m "vX.Y.Z" # asks for approval (§4.4); push on explicit request (§4.5)
41
+ ```
42
+
43
+ ## DoD
44
+ - Correct SemVer bump; complete CHANGELOG; tag + rollback plan ready.
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: security-scan
3
+ description: |
4
+ Stack-agnostic security audit: map the attack surface, trace untrusted input to dangerous calls, surface
5
+ dependency and configuration flaws. Severity-ranked report with fixes.
6
+ Use when auth, input handling, secrets or dependencies change, and before a release.
7
+ ---
8
+
9
+ # Security Scan
10
+
11
+ <!-- routing-eval reads the next line; why it sits in the body: AGENT_TEMPLATE.md -->
12
+ Trigger phrases: "security scan", "run a security scan", "OWASP check", "scan for vulnerabilities", "find security vulnerabilities", "security audit", "api key", "secret key", "leaked credential", "credentials leaked", "hardcoded secret", "hardcoded password", "sql injection", "can an attacker"
13
+
14
+ The core of a security vulnerability fits in a single sentence: **an untrusted input reaches a
15
+ dangerous operation without being adequately checked.** This skill chases exactly that sentence — it first
16
+ looks for where the input comes from, then where it flows, and what gate should sit in between.
17
+ It is stack-agnostic: whatever the language/framework, the same logic applies; when current tooling and
18
+ patterns are needed, it runs a web search.
19
+
20
+ > **Crewforth adaptation (local, .claude/):** `crew-security-expert` applies this; findings are carried to
21
+ > **crew-review-agent** in severity order, whatever the stack. Automatic
22
+ > fixes only with explicit approval (§4.4); `.claude` does not go to the repo (§4.3). §4 Prohibitions apply.
23
+
24
+ ## What it does, what it doesn't
25
+ - **Does:** surfaces common vulnerability classes, known vulnerable dependencies, and risky configuration; ties each finding to a concrete fix.
26
+ - **Doesn't:** does not replace a professional pentest / SAST / DAST. The report **guides**, it does not give full assurance — state this at the end of the report.
27
+ - **Boundary:** analysis is local; code/data is not sent to an external service, and the project directory is not left.
28
+
29
+ ## A question is not a scan
30
+ Loading this skill does not mean running all of it. "Is this query injectable?", "should this key be in the
31
+ repo?", "how do I hash these passwords?" are **questions**: answer them from the relevant part of this skill and
32
+ stop — no discovery pass, no fan-out of verifiers, no coverage ledger, no report file. The full workflow below runs
33
+ when the user asks for a scan, an audit or a security review of a codebase or a change, or asks for the report
34
+ itself. When a request could be either, ask one question before starting the full workflow; do not guess upward.
35
+
36
+ ## Mental model — source → gate → sink
37
+ Reduce every check to three questions:
38
+ 1. **Source** — where does the input enter? (route, API endpoint, form, CLI argument, file upload, WebSocket, queue message, external API response)
39
+ 2. **Sink** — which dangerous operation does this input reach? (SQL execution, shell, file path, HTML render, deserialization, template)
40
+ 3. **Gate** — is there validation / parameterization / escaping / authorization in between? If not, that's the finding.
41
+
42
+ The scan applies this model on four fronts: **dependency · code · configuration · authorization**. The result is ranked by severity, and the fix is presented for the user to choose.
43
+
44
+ ## Scope
45
+ Prefer **`docs/THREAT_MODEL.md`** if present (from the `threat-model` skill): its entry points and attack classes
46
+ are the focus areas, and its impact/likelihood bias which findings count as high severity — the biggest lever on
47
+ false positives. No threat model → map the surface yourself first (Front 0 · Discovery).
48
+
49
+ ## Checklist
50
+ - [ ] Stack and package ecosystem(s) detected, attack surface mapped
51
+ - [ ] Dependency audit run for each ecosystem
52
+ - [ ] Source→sink paths traced across the four vulnerability classes
53
+ - [ ] Configuration and secret leakage scanned
54
+ - [ ] Authorization matrix produced, unprotected sensitive endpoints searched for
55
+ - [ ] Code builds on a model (prompts, retrieval, memory, tools, sub-agents, MCP) → Front 5 run (`references/ai-agents.md`)
56
+ - [ ] Each candidate adversarially **verified** (N-verifier disprove pass); FALSE_POSITIVE / CANNOT_VERIFY separated out
57
+ - [ ] Severity **derived from preconditions × access** (not the scanner's category); verification ≠ severity
58
+ - [ ] Findings reported in severity order, no secret disclosed; ruled-out findings recorded too
59
+ - [ ] Fix options presented to the user
60
+
61
+ ---
62
+
63
+ ## Fronts
64
+
65
+ Five review fronts — Discovery · Dependencies · Code (source→sink) · Configuration · Authorization: **`references/fronts.md`** (read the fronts you're scanning). A sixth, for code built on a model — prompts, retrieval, memory, tools, sub-agents, MCP — lives in **`references/ai-agents.md`**: read it only when that code is present.
66
+
67
+ When you fan out a sub-agent per front, how you prompt it decides recall — describe vulnerability **shapes** not a
68
+ checklist, scope each agent, and state that vulnerabilities exist: **`references/prompting.md`**.
69
+
70
+ ---
71
+
72
+ ## Verify before you report
73
+
74
+ Discovery is deliberately noisy (recall-biased); a **separate adversarial pass** disproves each candidate before it
75
+ reaches the report — the biggest lever on false positives. Run **N independent verifiers** per finding (each starts
76
+ from the code, not the summary; each hunts for why it's *wrong*), classify **TRUE_POSITIVE / FALSE_POSITIVE /
77
+ CANNOT_VERIFY**, then derive **severity from preconditions × access** (independently — "real" is not "critical").
78
+ The verifier procedure, the false-positive exclusion rules, the parseable verdict block, and the severity matrix
79
+ live in **`references/verify.md`**. Ruled-out findings are recorded, not silently dropped.
80
+
81
+ ## Report
82
+
83
+ The severity scale, finding format, summary line, and the fix-presentation format live in **`references/reporting.md`**.
84
+
85
+ ## Invariant rules
86
+ 1. **Guides, does not assure** — it does not replace a professional audit; say so in the report.
87
+ 2. **State coverage, not just findings** — every report ends with a `complete / partial / unknown` ledger over the
88
+ threat model's surfaces, each non-complete row carrying its reason. Without it, "no findings" and "never
89
+ looked" read identically to whoever acts on the report (`references/reporting.md`).
90
+ 3. **Mask secrets** — only the first 4 + last 4 characters (`sk-p…i789`); never write the full secret.
91
+ 4. **No automatic fix without approval** — even if "Fix everything" is chosen, first show what will change.
92
+ 5. **Do not install tools without asking.**
93
+ 6. **Preserve behavior** — a fix must not change functionality beyond closing the vulnerability.
94
+ 7. **Stay local** — do not send code/data to an external service, do not cross the project boundary.
95
+ 8. **Do not run the code under review to prove a finding** — no build, test, install or fixture run of it unless it
96
+ is isolated: no network, an empty environment, writes confined to a scratch directory, and hard limits on time
97
+ and resources. An install runs the target's own scripts; a test run executes whatever the target chose. If that
98
+ isolation is not available, the finding stays **CANNOT_VERIFY** with the exact local check that would settle
99
+ it. Reading source never needs any of this; executing it always does.