cclaw-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +100 -0
  3. package/dist/cli.d.ts +10 -0
  4. package/dist/cli.js +101 -0
  5. package/dist/config.d.ts +5 -0
  6. package/dist/config.js +70 -0
  7. package/dist/constants.d.ts +12 -0
  8. package/dist/constants.js +50 -0
  9. package/dist/content/agents.d.ts +39 -0
  10. package/dist/content/agents.js +244 -0
  11. package/dist/content/autoplan.d.ts +7 -0
  12. package/dist/content/autoplan.js +297 -0
  13. package/dist/content/contracts.d.ts +2 -0
  14. package/dist/content/contracts.js +50 -0
  15. package/dist/content/examples.d.ts +2 -0
  16. package/dist/content/examples.js +327 -0
  17. package/dist/content/hooks.d.ts +16 -0
  18. package/dist/content/hooks.js +753 -0
  19. package/dist/content/learnings.d.ts +5 -0
  20. package/dist/content/learnings.js +265 -0
  21. package/dist/content/meta-skill.d.ts +10 -0
  22. package/dist/content/meta-skill.js +137 -0
  23. package/dist/content/observe.d.ts +21 -0
  24. package/dist/content/observe.js +1110 -0
  25. package/dist/content/session-hooks.d.ts +7 -0
  26. package/dist/content/session-hooks.js +137 -0
  27. package/dist/content/skills.d.ts +3 -0
  28. package/dist/content/skills.js +257 -0
  29. package/dist/content/stage-schema.d.ts +78 -0
  30. package/dist/content/stage-schema.js +1453 -0
  31. package/dist/content/subagents.d.ts +13 -0
  32. package/dist/content/subagents.js +616 -0
  33. package/dist/content/templates.d.ts +3 -0
  34. package/dist/content/templates.js +272 -0
  35. package/dist/content/utility-skills.d.ts +12 -0
  36. package/dist/content/utility-skills.js +467 -0
  37. package/dist/doctor.d.ts +7 -0
  38. package/dist/doctor.js +610 -0
  39. package/dist/flow-state.d.ts +19 -0
  40. package/dist/flow-state.js +41 -0
  41. package/dist/fs-utils.d.ts +5 -0
  42. package/dist/fs-utils.js +28 -0
  43. package/dist/gitignore.d.ts +3 -0
  44. package/dist/gitignore.js +43 -0
  45. package/dist/harness-adapters.d.ts +12 -0
  46. package/dist/harness-adapters.js +175 -0
  47. package/dist/install.d.ts +9 -0
  48. package/dist/install.js +562 -0
  49. package/dist/learnings-summarizer.d.ts +25 -0
  50. package/dist/learnings-summarizer.js +201 -0
  51. package/dist/logger.d.ts +3 -0
  52. package/dist/logger.js +6 -0
  53. package/dist/policy.d.ts +6 -0
  54. package/dist/policy.js +179 -0
  55. package/dist/runs.d.ts +18 -0
  56. package/dist/runs.js +446 -0
  57. package/dist/types.d.ts +19 -0
  58. package/dist/types.js +12 -0
  59. package/package.json +47 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # cclaw
2
+
3
+ **A focused, installer-first workflow that turns AI coding sessions into predictable shipped outcomes.**
4
+
5
+ `cclaw` gives your agent one clear path:
6
+ **brainstorm -> scope -> design -> spec -> plan -> test -> build -> review -> ship**
7
+
8
+ No giant command jungle. No runtime daemon. No process theater.
9
+ Just a disciplined flow that stays lightweight and works across major coding harnesses.
10
+
11
+ ## How It Works
12
+
13
+ ```mermaid
14
+ flowchart LR
15
+ A[Idea] --> B[Brainstorm]
16
+ B --> C[Scope]
17
+ C --> D[Design]
18
+ D --> E[Spec]
19
+ E --> F[Plan]
20
+ F --> G[Test]
21
+ G --> H[Build]
22
+ H --> I[Review]
23
+ I --> J[Ship]
24
+ ```
25
+
26
+ ```mermaid
27
+ sequenceDiagram
28
+ participant U as User
29
+ participant H as Harness
30
+ participant V as cclaw Hooks + Skills
31
+ participant S as State + Learnings
32
+ U->>H: /cc-brainstorm
33
+ H->>V: Load stage contract + HARD-GATE
34
+ V->>S: Read context (state/learnings)
35
+ V-->>H: Structured execution guidance
36
+ H->>S: Write artifacts + checkpoint
37
+ S-->>U: Next stage is explicit
38
+ ```
39
+
40
+ ## Why `cclaw` Wins In Practice
41
+
42
+ - **Low cognitive load:** one canonical stage flow instead of dozens of competing paths.
43
+ - **Installer-first architecture:** generates files and hooks; does not run a hidden control plane.
44
+ - **Hard-gated quality:** each stage has non-skippable constraints that reduce AI drift.
45
+ - **Cross-harness parity:** same behavior model across Claude Code, Cursor, Codex, OpenCode.
46
+ - **Compounding context:** flow state + learnings get rehydrated on new sessions automatically.
47
+ - **Run-scoped execution:** each flow works against an active run with explicit handoff state.
48
+
49
+ ## Compared To Top References
50
+
51
+ | System | Strongest trait | Where `cclaw` is better |
52
+ |---|---|---|
53
+ | **Superpowers** | Rich skill ecosystem and mature workflows | Smaller operational surface, tighter stage discipline, faster onboarding for teams that want one default path |
54
+ | **G-Stack** | Deep multi-role orchestration (CEO/design/eng/release style) | Less overhead, fewer moving parts, easier to keep deterministic in day-to-day product delivery |
55
+ | **Everything Claude Code** | Broad command catalog and flexible patterns | Lower command entropy, clearer defaults, less decision fatigue for regular execution |
56
+
57
+ `cclaw` is intentionally opinionated: it optimizes for **signal over volume**.
58
+
59
+ ## 60-Second Start
60
+
61
+ ```bash
62
+ npx cclaw-cli init
63
+ ```
64
+
65
+ Then run in your harness:
66
+
67
+ ```text
68
+ /cc-brainstorm
69
+ ```
70
+
71
+ Core installer lifecycle:
72
+
73
+ ```bash
74
+ npx cclaw-cli sync
75
+ npx cclaw-cli doctor
76
+ npx cclaw-cli upgrade
77
+ npx cclaw-cli uninstall
78
+ ```
79
+
80
+ ## What Gets Generated
81
+
82
+ ```text
83
+ .cclaw/
84
+ ├── skills/
85
+ ├── commands/
86
+ ├── hooks/
87
+ ├── templates/
88
+ ├── artifacts/ # active mirror for current run (fallback path)
89
+ ├── state/
90
+ ├── runs/
91
+ │ └── <activeRunId>/
92
+ │ ├── artifacts/ # canonical run artifacts
93
+ │ ├── run.json
94
+ │ └── 00-handoff.md
95
+ └── learnings.jsonl
96
+ ```
97
+
98
+ ## License
99
+
100
+ [MIT](./LICENSE)
package/dist/cli.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import type { HarnessId } from "./types.js";
3
+ type CommandName = "init" | "sync" | "doctor" | "upgrade" | "uninstall";
4
+ interface ParsedArgs {
5
+ command?: CommandName;
6
+ harnesses?: HarnessId[];
7
+ }
8
+ declare function parseHarnesses(raw: string): HarnessId[];
9
+ declare function parseArgs(argv: string[]): ParsedArgs;
10
+ export { parseArgs, parseHarnesses };
package/dist/cli.js ADDED
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { HARNESS_IDS } from "./types.js";
6
+ import { doctorChecks, doctorSucceeded } from "./doctor.js";
7
+ import { initCclaw, syncCclaw, uninstallCclaw, upgradeCclaw } from "./install.js";
8
+ import { error, info } from "./logger.js";
9
+ const INSTALLER_COMMANDS = ["init", "sync", "doctor", "upgrade", "uninstall"];
10
+ function usage() {
11
+ return `cclaw - installer-first flow toolkit
12
+
13
+ Usage:
14
+ cclaw init [--harnesses=claude,cursor,opencode,codex]
15
+ cclaw sync
16
+ cclaw doctor
17
+ cclaw upgrade
18
+ cclaw uninstall
19
+ `;
20
+ }
21
+ function parseHarnesses(raw) {
22
+ const requested = raw
23
+ .split(",")
24
+ .map((item) => item.trim())
25
+ .filter(Boolean);
26
+ const invalid = requested.filter((item) => !HARNESS_IDS.includes(item));
27
+ if (invalid.length > 0) {
28
+ throw new Error(`Unknown harnesses: ${invalid.join(", ")}`);
29
+ }
30
+ return requested;
31
+ }
32
+ function parseArgs(argv) {
33
+ const [commandRaw, ...flags] = argv;
34
+ const command = INSTALLER_COMMANDS.includes(commandRaw)
35
+ ? commandRaw
36
+ : undefined;
37
+ const parsed = { command };
38
+ for (const flag of flags) {
39
+ if (flag.startsWith("--harnesses=")) {
40
+ parsed.harnesses = parseHarnesses(flag.replace("--harnesses=", ""));
41
+ }
42
+ }
43
+ return parsed;
44
+ }
45
+ async function runCommand(parsed, ctx) {
46
+ const command = parsed.command;
47
+ if (!command) {
48
+ ctx.stderr.write(usage());
49
+ return 1;
50
+ }
51
+ if (command === "init") {
52
+ await initCclaw({
53
+ projectRoot: ctx.cwd,
54
+ harnesses: parsed.harnesses
55
+ });
56
+ info(ctx, "Initialized .cclaw runtime and generated harness shims");
57
+ return 0;
58
+ }
59
+ if (command === "sync") {
60
+ await syncCclaw(ctx.cwd);
61
+ info(ctx, "Synchronized harness shims from current .cclaw config");
62
+ return 0;
63
+ }
64
+ if (command === "doctor") {
65
+ const checks = await doctorChecks(ctx.cwd);
66
+ for (const check of checks) {
67
+ ctx.stdout.write(`${check.ok ? "PASS" : "FAIL"} ${check.name} :: ${check.details}\n`);
68
+ }
69
+ return doctorSucceeded(checks) ? 0 : 2;
70
+ }
71
+ if (command === "upgrade") {
72
+ await upgradeCclaw(ctx.cwd);
73
+ info(ctx, "Upgraded .cclaw runtime and regenerated generated files");
74
+ return 0;
75
+ }
76
+ await uninstallCclaw(ctx.cwd);
77
+ info(ctx, "Removed .cclaw runtime and generated shim files");
78
+ return 0;
79
+ }
80
+ async function main() {
81
+ const parsed = parseArgs(process.argv.slice(2));
82
+ const ctx = {
83
+ cwd: process.cwd(),
84
+ stdout: process.stdout,
85
+ stderr: process.stderr
86
+ };
87
+ try {
88
+ const code = await runCommand(parsed, ctx);
89
+ process.exitCode = code;
90
+ }
91
+ catch (err) {
92
+ error(ctx, err instanceof Error ? err.message : "Unknown error");
93
+ process.exitCode = 1;
94
+ }
95
+ }
96
+ const entryPath = process.argv[1] ? path.resolve(process.argv[1]) : "";
97
+ const modulePath = fileURLToPath(import.meta.url);
98
+ if (entryPath === modulePath) {
99
+ void main();
100
+ }
101
+ export { parseArgs, parseHarnesses };
@@ -0,0 +1,5 @@
1
+ import type { HarnessId, CclawConfig } from "./types.js";
2
+ export declare function configPath(projectRoot: string): string;
3
+ export declare function createDefaultConfig(harnesses?: HarnessId[]): CclawConfig;
4
+ export declare function readConfig(projectRoot: string): Promise<CclawConfig>;
5
+ export declare function writeConfig(projectRoot: string, config: CclawConfig): Promise<void>;
package/dist/config.js ADDED
@@ -0,0 +1,70 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { parse, stringify } from "yaml";
4
+ import { DEFAULT_HARNESSES, FLOW_VERSION, RUNTIME_ROOT, CCLAW_VERSION } from "./constants.js";
5
+ import { exists, writeFileSafe } from "./fs-utils.js";
6
+ import { HARNESS_IDS } from "./types.js";
7
+ const CONFIG_PATH = `${RUNTIME_ROOT}/config.yaml`;
8
+ const HARNESS_ID_SET = new Set(HARNESS_IDS);
9
+ const SUPPORTED_HARNESSES_TEXT = HARNESS_IDS.join(", ");
10
+ function configFixExample() {
11
+ return `harnesses:
12
+ - claude
13
+ - cursor`;
14
+ }
15
+ function configValidationError(configFilePath, reason) {
16
+ return new Error(`Invalid cclaw config at ${configFilePath}: ${reason}\n` +
17
+ `Supported harnesses: ${SUPPORTED_HARNESSES_TEXT}\n` +
18
+ `Example config:\n${configFixExample()}\n` +
19
+ `After fixing, run: cclaw sync`);
20
+ }
21
+ export function configPath(projectRoot) {
22
+ return path.join(projectRoot, CONFIG_PATH);
23
+ }
24
+ export function createDefaultConfig(harnesses = DEFAULT_HARNESSES) {
25
+ return {
26
+ version: CCLAW_VERSION,
27
+ flowVersion: FLOW_VERSION,
28
+ harnesses
29
+ };
30
+ }
31
+ export async function readConfig(projectRoot) {
32
+ const fullPath = configPath(projectRoot);
33
+ if (!(await exists(fullPath))) {
34
+ return createDefaultConfig();
35
+ }
36
+ let parsedUnknown;
37
+ try {
38
+ parsedUnknown = parse(await fs.readFile(fullPath, "utf8"));
39
+ }
40
+ catch {
41
+ return createDefaultConfig();
42
+ }
43
+ const parsed = (parsedUnknown && typeof parsedUnknown === "object"
44
+ ? parsedUnknown
45
+ : {});
46
+ const hasHarnessesField = Object.prototype.hasOwnProperty.call(parsed, "harnesses");
47
+ if (hasHarnessesField && !Array.isArray(parsed.harnesses)) {
48
+ throw configValidationError(fullPath, `"harnesses" must be an array`);
49
+ }
50
+ const configuredHarnesses = (parsed.harnesses ?? []);
51
+ const invalidHarnesses = configuredHarnesses.filter((harness) => typeof harness !== "string" || !HARNESS_ID_SET.has(harness));
52
+ if (invalidHarnesses.length > 0) {
53
+ const formatted = invalidHarnesses
54
+ .map((item) => (typeof item === "string" ? item : JSON.stringify(item)))
55
+ .join(", ");
56
+ throw configValidationError(fullPath, `unknown harness id(s): ${formatted}`);
57
+ }
58
+ const validatedHarnesses = configuredHarnesses;
59
+ const harnesses = hasHarnessesField
60
+ ? [...new Set(validatedHarnesses)]
61
+ : DEFAULT_HARNESSES;
62
+ return {
63
+ version: parsed.version ?? CCLAW_VERSION,
64
+ flowVersion: parsed.flowVersion ?? FLOW_VERSION,
65
+ harnesses
66
+ };
67
+ }
68
+ export async function writeConfig(projectRoot, config) {
69
+ await writeFileSafe(configPath(projectRoot), stringify(config));
70
+ }
@@ -0,0 +1,12 @@
1
+ import type { FlowStage, HarnessId } from "./types.js";
2
+ /** Hidden runtime directory at project root (dot-prefixed). */
3
+ export declare const RUNTIME_ROOT = ".cclaw";
4
+ export declare const CCLAW_VERSION = "0.1.0";
5
+ export declare const FLOW_VERSION = "1.0.0";
6
+ export declare const DEFAULT_HARNESSES: HarnessId[];
7
+ export declare const REQUIRED_DIRS: readonly [".cclaw", ".cclaw/commands", ".cclaw/skills", ".cclaw/templates", ".cclaw/artifacts", ".cclaw/state", ".cclaw/runs", ".cclaw/rules", ".cclaw/adapters", ".cclaw/agents", ".cclaw/hooks"];
8
+ export declare const REQUIRED_GITIGNORE_PATTERNS: readonly ["# cclaw generated artifacts", ".cclaw/", ".claude/commands/cc-*.md", ".cursor/commands/cc-*.md", ".opencode/commands/cc-*.md", ".codex/commands/cc-*.md", ".claude/hooks/hooks.json", ".cursor/hooks.json", ".codex/hooks.json"];
9
+ export declare const COMMAND_FILE_ORDER: FlowStage[];
10
+ export declare const UTILITY_COMMANDS: readonly ["learn", "autoplan"];
11
+ export declare const SUBAGENT_SKILL_FOLDERS: readonly ["subagent-dev", "parallel-dispatch"];
12
+ export type UtilityCommand = (typeof UTILITY_COMMANDS)[number];
@@ -0,0 +1,50 @@
1
+ /** Hidden runtime directory at project root (dot-prefixed). */
2
+ export const RUNTIME_ROOT = ".cclaw";
3
+ export const CCLAW_VERSION = "0.1.0";
4
+ export const FLOW_VERSION = "1.0.0";
5
+ export const DEFAULT_HARNESSES = [
6
+ "claude",
7
+ "cursor",
8
+ "opencode",
9
+ "codex"
10
+ ];
11
+ export const REQUIRED_DIRS = [
12
+ RUNTIME_ROOT,
13
+ `${RUNTIME_ROOT}/commands`,
14
+ `${RUNTIME_ROOT}/skills`,
15
+ `${RUNTIME_ROOT}/templates`,
16
+ `${RUNTIME_ROOT}/artifacts`,
17
+ `${RUNTIME_ROOT}/state`,
18
+ `${RUNTIME_ROOT}/runs`,
19
+ `${RUNTIME_ROOT}/rules`,
20
+ `${RUNTIME_ROOT}/adapters`,
21
+ `${RUNTIME_ROOT}/agents`,
22
+ `${RUNTIME_ROOT}/hooks`
23
+ ];
24
+ export const REQUIRED_GITIGNORE_PATTERNS = [
25
+ "# cclaw generated artifacts",
26
+ `${RUNTIME_ROOT}/`,
27
+ ".claude/commands/cc-*.md",
28
+ ".cursor/commands/cc-*.md",
29
+ ".opencode/commands/cc-*.md",
30
+ ".codex/commands/cc-*.md",
31
+ ".claude/hooks/hooks.json",
32
+ ".cursor/hooks.json",
33
+ ".codex/hooks.json"
34
+ ];
35
+ export const COMMAND_FILE_ORDER = [
36
+ "brainstorm",
37
+ "scope",
38
+ "design",
39
+ "spec",
40
+ "plan",
41
+ "test",
42
+ "build",
43
+ "review",
44
+ "ship"
45
+ ];
46
+ export const UTILITY_COMMANDS = ["learn", "autoplan"];
47
+ export const SUBAGENT_SKILL_FOLDERS = [
48
+ "subagent-dev",
49
+ "parallel-dispatch"
50
+ ];
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Agent persona content for Cclaw.
3
+ *
4
+ * Cclaw emits markdown agent definitions (`.md` with YAML frontmatter) that harnesses
5
+ * use for specialist delegation. Agents are isolated context windows with constrained
6
+ * tools; skills remain procedural recipes.
7
+ */
8
+ export interface AgentDefinition {
9
+ /** Kebab-case identifier, e.g. `"spec-reviewer"`. */
10
+ name: string;
11
+ /** When to invoke — include PROACTIVE / MUST BE USED style guidance for harnesses. */
12
+ description: string;
13
+ /** Allowed tools for this agent (harness-specific names). */
14
+ tools: string[];
15
+ /** Model tier for routing cost/latency vs depth. */
16
+ model: "fast" | "balanced" | "deep";
17
+ /** How the harness should treat activation relative to flow context. */
18
+ activation: "proactive" | "on-demand" | "mandatory";
19
+ /** Cclaw flow stages this agent is designed to support. */
20
+ relatedStages: string[];
21
+ /** Markdown body rendered below the YAML frontmatter. */
22
+ body: string;
23
+ }
24
+ /**
25
+ * Canonical specialist agents Cclaw can materialize under `.cclaw/agents/`.
26
+ */
27
+ export declare const CCLAW_AGENTS: AgentDefinition[];
28
+ /**
29
+ * Render a complete Cclaw agent markdown file (YAML frontmatter + body).
30
+ */
31
+ export declare function agentMarkdown(agent: AgentDefinition): string;
32
+ /**
33
+ * Markdown table mapping Cclaw slash commands to recommended specialist agents.
34
+ */
35
+ export declare function agentRoutingTable(): string;
36
+ /**
37
+ * AGENTS.md-ready section describing Cclaw’s specialist delegation model.
38
+ */
39
+ export declare function agentsAgentsMdBlock(): string;
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Agent persona content for Cclaw.
3
+ *
4
+ * Cclaw emits markdown agent definitions (`.md` with YAML frontmatter) that harnesses
5
+ * use for specialist delegation. Agents are isolated context windows with constrained
6
+ * tools; skills remain procedural recipes.
7
+ */
8
+ function yamlScalarString(value) {
9
+ // JSON double-quoted strings are valid YAML scalars and escape reliably.
10
+ return JSON.stringify(value);
11
+ }
12
+ function yamlFlowSequence(values) {
13
+ return JSON.stringify(values);
14
+ }
15
+ /**
16
+ * Canonical specialist agents Cclaw can materialize under `.cclaw/agents/`.
17
+ */
18
+ export const CCLAW_AGENTS = [
19
+ {
20
+ name: "planner",
21
+ description: "PROACTIVE: Use for complex features, ambiguous requirements, or multi-area refactors. MUST BE USED when the user asks for a plan, breakdown, sequencing, or risk register before coding.",
22
+ tools: ["Read", "Grep", "Glob", "WebSearch"],
23
+ model: "deep",
24
+ activation: "proactive",
25
+ relatedStages: ["brainstorm", "scope", "design", "spec", "plan"],
26
+ body: [
27
+ "You are an **implementation planning specialist** (staff engineer mindset).",
28
+ "",
29
+ "Expert at decomposing complex requirements into actionable plans. When invoked:",
30
+ "",
31
+ "1. **Analyze** the request scope and identify sub-problems (including implicit ones).",
32
+ "2. **Map** sub-problems to existing code, modules, and reusable components (cite what you read).",
33
+ "3. **Produce** a structured plan with:",
34
+ " - dependency graph (what blocks what)",
35
+ " - task ordering (parallelizable vs sequential)",
36
+ " - effort estimates (T-shirt sizes are fine; justify uncertainty)",
37
+ "4. **Flag** risks, unknowns, and decisions that need user input (no silent assumptions).",
38
+ "",
39
+ "**Role boundary:** Staff engineer who plans before coding. **Never write production code** — only plans, tradeoffs, and verification steps the builder should follow.",
40
+ ].join("\n"),
41
+ },
42
+ {
43
+ name: "spec-reviewer",
44
+ description: "MANDATORY after implementation: MUST BE USED during `/cc-review` (and any review gate) to verify acceptance criteria against the actual codebase — not against claims.",
45
+ tools: ["Read", "Grep", "Glob"],
46
+ model: "balanced",
47
+ activation: "mandatory",
48
+ relatedStages: ["review"],
49
+ body: [
50
+ "You are a **specification compliance reviewer**.",
51
+ "",
52
+ "Reviews implementation against spec criteria. For each acceptance criterion:",
53
+ "",
54
+ "1. **Locate** the implementing code (and tests if they are the specification).",
55
+ "2. **Verify** runtime behavior matches the criterion (not just naming or comments).",
56
+ "3. **Check** edge cases are handled (empty inputs, errors, concurrency, permissions, idempotency as applicable).",
57
+ "4. **Report** with one of:",
58
+ " - **PASS** — criterion met with evidence",
59
+ " - **PARTIAL** — partially met; describe the gap precisely",
60
+ " - **FAIL** — not met; describe why with evidence",
61
+ "",
62
+ "**Trust model:** Do **not** trust the implementer's claims. **Read the code yourself.** **Cite `file:line` for every finding.**",
63
+ ].join("\n"),
64
+ },
65
+ {
66
+ name: "code-reviewer",
67
+ description: "MANDATORY for all code changes: MUST BE USED during `/cc-review` for any diff/PR-sized work — correctness, maintainability, and ship risk.",
68
+ tools: ["Read", "Grep", "Glob"],
69
+ model: "balanced",
70
+ activation: "mandatory",
71
+ relatedStages: ["review"],
72
+ body: [
73
+ "You are a **code quality reviewer** across five dimensions:",
74
+ "",
75
+ "- **Correctness** — logic, data flow, error handling, boundary conditions",
76
+ "- **Readability** — naming, structure, comments (high signal only)",
77
+ "- **Architecture** — boundaries, coupling, extensibility, layering",
78
+ "- **Security** — trust boundaries, dangerous APIs, secret handling (deep dive belongs to `security-reviewer`)",
79
+ "- **Performance** — hot paths, accidental quadratic behavior, IO/network pitfalls",
80
+ "",
81
+ "For each finding, include:",
82
+ "",
83
+ "- **Severity:** `Critical` (blocks ship) | `Important` (should fix) | `Suggestion` (optional)",
84
+ "- **Location:** `file:line`",
85
+ "- **Problem:** concrete description (what is wrong, not opinions)",
86
+ "- **Recommendation:** specific fix (patch-level guidance), not vague advice",
87
+ "",
88
+ "**Change-size norms (PR hygiene):**",
89
+ "",
90
+ "- ~**100** lines changed: normal",
91
+ "- ~**300** lines changed: consider splitting unless tightly cohesive",
92
+ "- ~**1000+** lines changed: strongly recommend stacked PRs / incremental delivery",
93
+ ].join("\n"),
94
+ },
95
+ {
96
+ name: "security-reviewer",
97
+ description: "PROACTIVE after auth, crypto, secrets, parsers, or sensitive data paths change. MUST BE USED when trust boundaries move, new external inputs arrive, or LLM/tool output influences privileged actions.",
98
+ tools: ["Read", "Grep", "Glob"],
99
+ model: "balanced",
100
+ activation: "proactive",
101
+ relatedStages: ["review", "design"],
102
+ body: [
103
+ "You are a **security vulnerability detection** specialist focused on practical exploitability.",
104
+ "",
105
+ "Check for (non-exhaustive):",
106
+ "",
107
+ "- input validation gaps (type confusion, unexpected encodings)",
108
+ "- SQL/NoSQL injection and unsafe query composition",
109
+ "- XSS/CSRF vectors (including stored XSS and DOM sinks)",
110
+ "- secrets in code/logs/metrics (tokens, keys, private URLs)",
111
+ "- auth boundary violations (IDOR, missing authorization, confused deputy)",
112
+ "- insecure deserialization / unsafe eval / dynamic code paths",
113
+ "- path traversal and unsafe file operations",
114
+ "- SSRF (especially against cloud metadata endpoints)",
115
+ "- trust boundary violations (**especially LLM output used without validation** before side effects)",
116
+ "",
117
+ "For each finding, include:",
118
+ "",
119
+ "- **severity** (Critical / Important / Suggestion — align with ship risk)",
120
+ "- **CWE ID** if applicable (or say UNKNOWN)",
121
+ "- **proof-of-concept attack vector** (short, concrete, no real weaponization steps beyond what’s needed to show impact)",
122
+ "- **recommended fix** (specific controls: validation, sandboxing, capability reduction, safe APIs)",
123
+ ].join("\n"),
124
+ },
125
+ {
126
+ name: "test-author",
127
+ description: "PROACTIVE for new features and bug fixes: MUST BE USED when behavior changes require regression protection, when risk is high, or when the user asks for TDD.",
128
+ tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"],
129
+ model: "balanced",
130
+ activation: "proactive",
131
+ relatedStages: ["test", "build"],
132
+ body: [
133
+ "You are a **test-driven development** guide and implementer.",
134
+ "",
135
+ "**Iron law:** no production code without a **failing test first**.",
136
+ "",
137
+ "**Process:**",
138
+ "",
139
+ "1. **RED** — write a failing test that expresses the desired behavior.",
140
+ "2. **Verify RED** — the test must fail for the *right reason* (not compilation/setup noise).",
141
+ "3. **GREEN** — write the minimal production code to pass.",
142
+ "4. **Verify GREEN** — all tests pass (not just the new one).",
143
+ "5. **REFACTOR** — improve design while keeping tests green.",
144
+ "",
145
+ "**Test design principles:**",
146
+ "",
147
+ "- prefer **behavior** over implementation details",
148
+ "- prefer **DAMP** over DRY when it improves readability of failures",
149
+ "- aim for a healthy pyramid: lots of small fast tests, fewer medium integration tests, few large end-to-end tests (use judgment for the codebase)",
150
+ "",
151
+ "**Bug fixes:** write a test that reproduces the bug **first** (RED), then fix (GREEN), then refactor if needed.",
152
+ ].join("\n"),
153
+ },
154
+ {
155
+ name: "doc-updater",
156
+ description: "PROACTIVE after code changes: SHOULD BE USED when public behavior, configuration, CLI flags, APIs, or operational runbooks may have drifted from docs.",
157
+ tools: ["Read", "Write", "Edit", "Grep", "Glob"],
158
+ model: "fast",
159
+ activation: "proactive",
160
+ relatedStages: ["build", "ship"],
161
+ body: [
162
+ "You are a **documentation and comment maintenance** specialist.",
163
+ "",
164
+ "After code changes, check:",
165
+ "",
166
+ "- are README/docs still accurate (setup, usage, examples)?",
167
+ "- are API docs / exported surface docs current?",
168
+ "- are comments still describing real behavior (not stale narratives)?",
169
+ "",
170
+ "**Scope control:** only update what needs updating — **do not rewrite** docs that remain correct.",
171
+ ].join("\n"),
172
+ },
173
+ ];
174
+ import { enhancedAgentBody } from "./subagents.js";
175
+ /**
176
+ * Render a complete Cclaw agent markdown file (YAML frontmatter + body).
177
+ */
178
+ export function agentMarkdown(agent) {
179
+ const frontmatter = [
180
+ "---",
181
+ `name: ${agent.name}`,
182
+ `description: ${yamlScalarString(agent.description)}`,
183
+ `tools: ${yamlFlowSequence(agent.tools)}`,
184
+ `model: ${agent.model}`,
185
+ "---",
186
+ ].join("\n");
187
+ const relatedStages = agent.relatedStages.length > 0 ? agent.relatedStages.join(", ") : "(none)";
188
+ const taskDelegation = enhancedAgentBody(agent.name);
189
+ return `${frontmatter}
190
+
191
+ # ${agent.name}
192
+
193
+ ${agent.body}
194
+
195
+ ## Activation
196
+
197
+ - Mode: ${agent.activation}
198
+ - Related stages: ${relatedStages}
199
+
200
+ ## Rules
201
+
202
+ - Cite file:line for every finding
203
+ - Do not make changes outside your specialist domain
204
+ - Report findings with severity classification
205
+ - If uncertain, say "UNKNOWN" — never guess
206
+
207
+ ${taskDelegation}
208
+ `;
209
+ }
210
+ /**
211
+ * Markdown table mapping Cclaw slash commands to recommended specialist agents.
212
+ */
213
+ export function agentRoutingTable() {
214
+ return `| Command | Primary Agent | Supporting Agents |
215
+ |---|---|---|
216
+ | /cc-brainstorm | planner | — |
217
+ | /cc-scope | planner | — |
218
+ | /cc-design | planner, security-reviewer | — |
219
+ | /cc-spec | planner | spec-reviewer |
220
+ | /cc-plan | planner | — |
221
+ | /cc-test | test-author | — |
222
+ | /cc-build | test-author | doc-updater |
223
+ | /cc-review | spec-reviewer, code-reviewer | security-reviewer |
224
+ | /cc-ship | — | doc-updater |
225
+ `;
226
+ }
227
+ /**
228
+ * AGENTS.md-ready section describing Cclaw’s specialist delegation model.
229
+ */
230
+ export function agentsAgentsMdBlock() {
231
+ return `### Agent Specialists
232
+
233
+ Cclaw provides specialist agents under \`.cclaw/agents/\` for targeted delegation via the Task tool.
234
+
235
+ ${agentRoutingTable()}
236
+
237
+ **Activation modes:**
238
+ - **Mandatory:** MUST be used when the related stage runs (spec-reviewer, code-reviewer during /review)
239
+ - **Proactive:** Should be used automatically when context matches (planner for complex features, security-reviewer for auth code)
240
+ - **On-demand:** Invoked only when explicitly requested
241
+
242
+ **Agent files:** \`.cclaw/agents/{name}.md\` — each contains YAML frontmatter with tools and model tier.
243
+ `;
244
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Autoplan orchestrator content for cclaw.
3
+ * Generates markdown instructions that AI agents follow; cclaw does not execute the pipeline.
4
+ */
5
+ export declare function autoplanSkillMarkdown(): string;
6
+ export declare function autoplanCommandContract(): string;
7
+ export declare function autoplanAgentsMdBlock(): string;