work-kit-cli 0.2.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 (76) hide show
  1. package/README.md +147 -0
  2. package/cli/bin/work-kit.mjs +21 -0
  3. package/cli/src/commands/complete.ts +163 -0
  4. package/cli/src/commands/completions.ts +137 -0
  5. package/cli/src/commands/context.ts +41 -0
  6. package/cli/src/commands/doctor.ts +79 -0
  7. package/cli/src/commands/init.test.ts +116 -0
  8. package/cli/src/commands/init.ts +184 -0
  9. package/cli/src/commands/loopback.ts +64 -0
  10. package/cli/src/commands/next.ts +172 -0
  11. package/cli/src/commands/observe.ts +144 -0
  12. package/cli/src/commands/setup.ts +159 -0
  13. package/cli/src/commands/status.ts +50 -0
  14. package/cli/src/commands/uninstall.ts +89 -0
  15. package/cli/src/commands/upgrade.ts +12 -0
  16. package/cli/src/commands/validate.ts +34 -0
  17. package/cli/src/commands/workflow.ts +125 -0
  18. package/cli/src/config/agent-map.ts +62 -0
  19. package/cli/src/config/loopback-routes.ts +45 -0
  20. package/cli/src/config/phases.ts +119 -0
  21. package/cli/src/context/extractor.test.ts +77 -0
  22. package/cli/src/context/extractor.ts +73 -0
  23. package/cli/src/context/prompt-builder.ts +70 -0
  24. package/cli/src/engine/loopbacks.test.ts +33 -0
  25. package/cli/src/engine/loopbacks.ts +32 -0
  26. package/cli/src/engine/parallel.ts +60 -0
  27. package/cli/src/engine/phases.ts +23 -0
  28. package/cli/src/engine/transitions.test.ts +117 -0
  29. package/cli/src/engine/transitions.ts +97 -0
  30. package/cli/src/index.ts +253 -0
  31. package/cli/src/observer/data.ts +267 -0
  32. package/cli/src/observer/renderer.ts +364 -0
  33. package/cli/src/observer/watcher.ts +104 -0
  34. package/cli/src/state/helpers.test.ts +91 -0
  35. package/cli/src/state/helpers.ts +65 -0
  36. package/cli/src/state/schema.ts +113 -0
  37. package/cli/src/state/store.ts +82 -0
  38. package/cli/src/state/validators.test.ts +105 -0
  39. package/cli/src/state/validators.ts +81 -0
  40. package/cli/src/utils/colors.ts +12 -0
  41. package/package.json +50 -0
  42. package/skills/auto-kit/SKILL.md +216 -0
  43. package/skills/build/SKILL.md +88 -0
  44. package/skills/build/stages/commit.md +43 -0
  45. package/skills/build/stages/core.md +48 -0
  46. package/skills/build/stages/integration.md +44 -0
  47. package/skills/build/stages/migration.md +41 -0
  48. package/skills/build/stages/red.md +44 -0
  49. package/skills/build/stages/refactor.md +48 -0
  50. package/skills/build/stages/setup.md +42 -0
  51. package/skills/build/stages/ui.md +51 -0
  52. package/skills/deploy/SKILL.md +62 -0
  53. package/skills/deploy/stages/merge.md +59 -0
  54. package/skills/deploy/stages/monitor.md +39 -0
  55. package/skills/deploy/stages/remediate.md +54 -0
  56. package/skills/full-kit/SKILL.md +197 -0
  57. package/skills/plan/SKILL.md +77 -0
  58. package/skills/plan/stages/architecture.md +53 -0
  59. package/skills/plan/stages/audit.md +58 -0
  60. package/skills/plan/stages/blueprint.md +60 -0
  61. package/skills/plan/stages/clarify.md +61 -0
  62. package/skills/plan/stages/investigate.md +47 -0
  63. package/skills/plan/stages/scope.md +46 -0
  64. package/skills/plan/stages/sketch.md +44 -0
  65. package/skills/plan/stages/ux-flow.md +49 -0
  66. package/skills/review/SKILL.md +104 -0
  67. package/skills/review/stages/compliance.md +48 -0
  68. package/skills/review/stages/handoff.md +59 -0
  69. package/skills/review/stages/performance.md +45 -0
  70. package/skills/review/stages/security.md +49 -0
  71. package/skills/review/stages/self-review.md +41 -0
  72. package/skills/test/SKILL.md +83 -0
  73. package/skills/test/stages/e2e.md +44 -0
  74. package/skills/test/stages/validate.md +51 -0
  75. package/skills/test/stages/verify.md +41 -0
  76. package/skills/wrap-up/SKILL.md +81 -0
@@ -0,0 +1,113 @@
1
+ // ── Phase & Sub-stage Types ──────────────────────────────────────────
2
+
3
+ export const PHASE_NAMES = ["plan", "build", "test", "review", "deploy", "wrap-up"] as const;
4
+ export type PhaseName = (typeof PHASE_NAMES)[number];
5
+
6
+ export const PLAN_SUBSTAGES = ["clarify", "investigate", "sketch", "scope", "ux-flow", "architecture", "blueprint", "audit"] as const;
7
+ export const BUILD_SUBSTAGES = ["setup", "migration", "red", "core", "ui", "refactor", "integration", "commit"] as const;
8
+ export const TEST_SUBSTAGES = ["verify", "e2e", "validate"] as const;
9
+ export const REVIEW_SUBSTAGES = ["self-review", "security", "performance", "compliance", "handoff"] as const;
10
+ export const DEPLOY_SUBSTAGES = ["merge", "monitor", "remediate"] as const;
11
+ export const WRAPUP_SUBSTAGES = ["wrap-up"] as const;
12
+
13
+ export type PlanSubStage = (typeof PLAN_SUBSTAGES)[number];
14
+ export type BuildSubStage = (typeof BUILD_SUBSTAGES)[number];
15
+ export type TestSubStage = (typeof TEST_SUBSTAGES)[number];
16
+ export type ReviewSubStage = (typeof REVIEW_SUBSTAGES)[number];
17
+ export type DeploySubStage = (typeof DEPLOY_SUBSTAGES)[number];
18
+ export type WrapUpSubStage = (typeof WRAPUP_SUBSTAGES)[number];
19
+
20
+ export type SubStageName = PlanSubStage | BuildSubStage | TestSubStage | ReviewSubStage | DeploySubStage | WrapUpSubStage;
21
+
22
+ export const SUBSTAGES_BY_PHASE: Record<PhaseName, readonly string[]> = {
23
+ plan: PLAN_SUBSTAGES,
24
+ build: BUILD_SUBSTAGES,
25
+ test: TEST_SUBSTAGES,
26
+ review: REVIEW_SUBSTAGES,
27
+ deploy: DEPLOY_SUBSTAGES,
28
+ "wrap-up": WRAPUP_SUBSTAGES,
29
+ };
30
+
31
+ // ── Classification ───────────────────────────────────────────────────
32
+
33
+ export type Classification = "bug-fix" | "small-change" | "refactor" | "feature" | "large-feature";
34
+
35
+ // ── Phase & Sub-stage State ──────────────────────────────────────────
36
+
37
+ export type PhaseStatus = "pending" | "in-progress" | "completed" | "skipped";
38
+ export type SubStageStatus = "pending" | "in-progress" | "completed" | "skipped";
39
+
40
+ export interface SubStageState {
41
+ status: SubStageStatus;
42
+ outcome?: string;
43
+ startedAt?: string;
44
+ completedAt?: string;
45
+ }
46
+
47
+ export interface PhaseState {
48
+ status: PhaseStatus;
49
+ subStages: Record<string, SubStageState>;
50
+ startedAt?: string;
51
+ completedAt?: string;
52
+ }
53
+
54
+ // ── Loopback ─────────────────────────────────────────────────────────
55
+
56
+ export interface Location {
57
+ phase: PhaseName;
58
+ subStage: string;
59
+ }
60
+
61
+ export interface LoopbackRecord {
62
+ from: Location;
63
+ to: Location;
64
+ reason: string;
65
+ timestamp: string;
66
+ }
67
+
68
+ // ── Workflow (auto-kit) ──────────────────────────────────────────────
69
+
70
+ export interface WorkflowStep {
71
+ phase: PhaseName;
72
+ subStage: string;
73
+ included: boolean;
74
+ }
75
+
76
+ // ── Main State ───────────────────────────────────────────────────────
77
+
78
+ export interface WorkKitState {
79
+ version: 1;
80
+ slug: string;
81
+ branch: string;
82
+ started: string;
83
+ mode: "full-kit" | "auto-kit";
84
+ classification?: Classification;
85
+ status: "in-progress" | "paused" | "completed" | "failed";
86
+ currentPhase: PhaseName | null;
87
+ currentSubStage: string | null;
88
+ phases: Record<PhaseName, PhaseState>;
89
+ workflow?: WorkflowStep[];
90
+ loopbacks: LoopbackRecord[];
91
+ metadata: {
92
+ worktreeRoot: string;
93
+ mainRepoRoot: string;
94
+ };
95
+ }
96
+
97
+ // ── Actions (CLI → Claude) ───────────────────────────────────────────
98
+
99
+ export interface AgentSpec {
100
+ phase: PhaseName;
101
+ subStage: string;
102
+ skillFile: string;
103
+ agentPrompt: string;
104
+ outputFile?: string; // for parallel agents writing to separate files
105
+ }
106
+
107
+ export type Action =
108
+ | { action: "spawn_agent"; phase: PhaseName; subStage: string; skillFile: string; agentPrompt: string; onComplete: string }
109
+ | { action: "spawn_parallel_agents"; agents: AgentSpec[]; thenSequential?: AgentSpec; onComplete: string }
110
+ | { action: "wait_for_user"; message: string }
111
+ | { action: "loopback"; from: Location; to: Location; reason: string }
112
+ | { action: "complete"; message: string }
113
+ | { action: "error"; message: string; suggestion?: string };
@@ -0,0 +1,82 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+ import { WorkKitState } from "./schema.js";
5
+
6
+ const STATE_DIR = ".work-kit";
7
+ const STATE_FILE = "state.json";
8
+
9
+ // ── Worktree Discovery ───────────────────────────────────────────────
10
+
11
+ export function findWorktreeRoot(startDir?: string): string | null {
12
+ let dir = startDir || process.cwd();
13
+ while (true) {
14
+ if (fs.existsSync(path.join(dir, STATE_DIR, STATE_FILE))) {
15
+ return dir;
16
+ }
17
+ const parent = path.dirname(dir);
18
+ if (parent === dir) return null;
19
+ dir = parent;
20
+ }
21
+ }
22
+
23
+ export function stateDir(worktreeRoot: string): string {
24
+ return path.join(worktreeRoot, STATE_DIR);
25
+ }
26
+
27
+ export function statePath(worktreeRoot: string): string {
28
+ return path.join(worktreeRoot, STATE_DIR, STATE_FILE);
29
+ }
30
+
31
+ export function stateMdPath(worktreeRoot: string): string {
32
+ return path.join(worktreeRoot, STATE_DIR, "state.md");
33
+ }
34
+
35
+ // ── Read / Write ─────────────────────────────────────────────────────
36
+
37
+ export function stateExists(worktreeRoot: string): boolean {
38
+ return fs.existsSync(statePath(worktreeRoot));
39
+ }
40
+
41
+ export function readState(worktreeRoot: string): WorkKitState {
42
+ const filePath = statePath(worktreeRoot);
43
+ if (!fs.existsSync(filePath)) {
44
+ throw new Error(`No state.json found at ${filePath}`);
45
+ }
46
+ const raw = fs.readFileSync(filePath, "utf-8");
47
+ try {
48
+ return JSON.parse(raw) as WorkKitState;
49
+ } catch {
50
+ throw new Error(`Corrupted state.json at ${filePath}. File contains invalid JSON.`);
51
+ }
52
+ }
53
+
54
+ export function writeState(worktreeRoot: string, state: WorkKitState): void {
55
+ const dir = stateDir(worktreeRoot);
56
+ if (!fs.existsSync(dir)) {
57
+ fs.mkdirSync(dir, { recursive: true });
58
+ }
59
+ const target = statePath(worktreeRoot);
60
+ const tmp = target + "." + randomUUID().slice(0, 8) + ".tmp";
61
+ fs.writeFileSync(tmp, JSON.stringify(state, null, 2) + "\n", "utf-8");
62
+ fs.renameSync(tmp, target);
63
+ }
64
+
65
+ // ── State.md ─────────────────────────────────────────────────────────
66
+
67
+ export function writeStateMd(worktreeRoot: string, content: string): void {
68
+ const dir = stateDir(worktreeRoot);
69
+ if (!fs.existsSync(dir)) {
70
+ fs.mkdirSync(dir, { recursive: true });
71
+ }
72
+ const target = stateMdPath(worktreeRoot);
73
+ const tmp = target + "." + randomUUID().slice(0, 8) + ".tmp";
74
+ fs.writeFileSync(tmp, content, "utf-8");
75
+ fs.renameSync(tmp, target);
76
+ }
77
+
78
+ export function readStateMd(worktreeRoot: string): string | null {
79
+ const filePath = stateMdPath(worktreeRoot);
80
+ if (!fs.existsSync(filePath)) return null;
81
+ return fs.readFileSync(filePath, "utf-8");
82
+ }
@@ -0,0 +1,105 @@
1
+ import { describe, it } from "node:test";
2
+ import * as assert from "node:assert/strict";
3
+ import { validatePhasePrerequisites } from "./validators.js";
4
+ import type { WorkKitState, PhaseName, PhaseState, SubStageState } from "./schema.js";
5
+ import { PHASE_NAMES, SUBSTAGES_BY_PHASE } from "./schema.js";
6
+
7
+ function makeState(): WorkKitState {
8
+ const phases = {} as Record<PhaseName, PhaseState>;
9
+ for (const phase of PHASE_NAMES) {
10
+ const subStages: Record<string, SubStageState> = {};
11
+ for (const ss of SUBSTAGES_BY_PHASE[phase]) {
12
+ subStages[ss] = { status: "pending" };
13
+ }
14
+ phases[phase] = { status: "pending", subStages };
15
+ }
16
+ return {
17
+ version: 1,
18
+ slug: "test",
19
+ branch: "feature/test",
20
+ started: "2026-01-01",
21
+ mode: "full-kit",
22
+ status: "in-progress",
23
+ currentPhase: "plan",
24
+ currentSubStage: "clarify",
25
+ phases,
26
+ loopbacks: [],
27
+ metadata: { worktreeRoot: "/tmp/test", mainRepoRoot: "/tmp/test" },
28
+ };
29
+ }
30
+
31
+ function completePhase(state: WorkKitState, phase: PhaseName): void {
32
+ state.phases[phase].status = "completed";
33
+ state.phases[phase].completedAt = "2026-01-01";
34
+ for (const ss of Object.values(state.phases[phase].subStages)) {
35
+ ss.status = "completed";
36
+ ss.completedAt = "2026-01-01";
37
+ }
38
+ }
39
+
40
+ describe("validatePhasePrerequisites", () => {
41
+ it("plan has no prerequisites — valid", () => {
42
+ const state = makeState();
43
+ const result = validatePhasePrerequisites(state, "plan");
44
+ assert.equal(result.valid, true);
45
+ });
46
+
47
+ it("build with plan incomplete — invalid", () => {
48
+ const state = makeState();
49
+ const result = validatePhasePrerequisites(state, "build");
50
+ assert.equal(result.valid, false);
51
+ assert.equal(result.missingPrerequisite, "plan");
52
+ });
53
+
54
+ it("build with plan complete — valid", () => {
55
+ const state = makeState();
56
+ completePhase(state, "plan");
57
+ const result = validatePhasePrerequisites(state, "build");
58
+ assert.equal(result.valid, true);
59
+ });
60
+
61
+ it("deploy with review complete but handoff not approved — invalid", () => {
62
+ const state = makeState();
63
+ completePhase(state, "plan");
64
+ completePhase(state, "build");
65
+ completePhase(state, "test");
66
+ completePhase(state, "review");
67
+ // handoff completed but without "approved" outcome
68
+ state.phases.review.subStages.handoff.outcome = "pending_review";
69
+ const result = validatePhasePrerequisites(state, "deploy");
70
+ assert.equal(result.valid, false);
71
+ });
72
+
73
+ it("deploy with review complete and handoff approved — valid", () => {
74
+ const state = makeState();
75
+ completePhase(state, "plan");
76
+ completePhase(state, "build");
77
+ completePhase(state, "test");
78
+ completePhase(state, "review");
79
+ state.phases.review.subStages.handoff.outcome = "approved";
80
+ const result = validatePhasePrerequisites(state, "deploy");
81
+ assert.equal(result.valid, true);
82
+ });
83
+
84
+ it("wrap-up with review complete — valid", () => {
85
+ const state = makeState();
86
+ completePhase(state, "plan");
87
+ completePhase(state, "build");
88
+ completePhase(state, "test");
89
+ completePhase(state, "review");
90
+ const result = validatePhasePrerequisites(state, "wrap-up");
91
+ assert.equal(result.valid, true);
92
+ });
93
+
94
+ it("wrap-up with deploy in-progress — invalid", () => {
95
+ const state = makeState();
96
+ completePhase(state, "plan");
97
+ completePhase(state, "build");
98
+ completePhase(state, "test");
99
+ completePhase(state, "review");
100
+ state.phases.deploy.status = "in-progress";
101
+ const result = validatePhasePrerequisites(state, "wrap-up");
102
+ assert.equal(result.valid, false);
103
+ assert.equal(result.missingPrerequisite, "deploy");
104
+ });
105
+ });
@@ -0,0 +1,81 @@
1
+ import { WorkKitState, PhaseName } from "./schema.js";
2
+ import { PHASE_PREREQUISITES } from "../config/phases.js";
3
+
4
+ export interface ValidationResult {
5
+ valid: boolean;
6
+ message: string;
7
+ missingPrerequisite?: PhaseName;
8
+ }
9
+
10
+ export function validatePhasePrerequisites(state: WorkKitState, phase: PhaseName): ValidationResult {
11
+ const prereq = PHASE_PREREQUISITES[phase];
12
+
13
+ if (!prereq) {
14
+ return { valid: true, message: `${phase} has no prerequisites` };
15
+ }
16
+
17
+ // Special case: wrap-up can proceed after review OR deploy
18
+ if (phase === "wrap-up") {
19
+ const reviewDone = state.phases.review.status === "completed";
20
+ const deployStatus = state.phases.deploy.status;
21
+
22
+ if (!reviewDone) {
23
+ return {
24
+ valid: false,
25
+ message: `wrap-up requires review to be complete. Current: ${state.phases.review.status}`,
26
+ missingPrerequisite: "review",
27
+ };
28
+ }
29
+
30
+ if (deployStatus === "in-progress") {
31
+ return {
32
+ valid: false,
33
+ message: `wrap-up requires deploy to finish first. Current: ${deployStatus}`,
34
+ missingPrerequisite: "deploy",
35
+ };
36
+ }
37
+
38
+ // deploy completed, skipped, or pending (never started) — all ok if review is done
39
+ return { valid: true, message: "Prerequisites met for wrap-up" };
40
+ }
41
+
42
+ // Special case: deploy requires review complete AND handoff approved
43
+ if (phase === "deploy") {
44
+ const reviewState = state.phases.review;
45
+ if (reviewState.status !== "completed") {
46
+ return {
47
+ valid: false,
48
+ message: `deploy requires review to be complete. Current: ${reviewState.status}`,
49
+ missingPrerequisite: "review",
50
+ };
51
+ }
52
+ const handoff = reviewState.subStages["handoff"];
53
+ if (!handoff) {
54
+ return {
55
+ valid: false,
56
+ message: `deploy requires review/handoff to exist and be approved. Handoff sub-stage not found.`,
57
+ missingPrerequisite: "review",
58
+ };
59
+ }
60
+ if (handoff.outcome !== "approved") {
61
+ return {
62
+ valid: false,
63
+ message: `deploy requires review/handoff outcome to be "approved". Current: ${handoff.outcome || "none"}`,
64
+ missingPrerequisite: "review",
65
+ };
66
+ }
67
+ return { valid: true, message: "Prerequisites met for deploy" };
68
+ }
69
+
70
+ // General case
71
+ const prereqState = state.phases[prereq];
72
+ if (prereqState.status !== "completed") {
73
+ return {
74
+ valid: false,
75
+ message: `${phase} requires ${prereq} to be complete. Current: ${prereqState.status}`,
76
+ missingPrerequisite: prereq,
77
+ };
78
+ }
79
+
80
+ return { valid: true, message: `Prerequisites met for ${phase}` };
81
+ }
@@ -0,0 +1,12 @@
1
+ const enabled = process.stdout.isTTY !== false && process.env.NO_COLOR === undefined;
2
+
3
+ const code = (n: number) => enabled ? `\x1b[${n}m` : "";
4
+ const reset = code(0);
5
+
6
+ export const bold = (s: string) => `${code(1)}${s}${reset}`;
7
+ export const dim = (s: string) => `${code(2)}${s}${reset}`;
8
+ export const green = (s: string) => `${code(32)}${s}${reset}`;
9
+ export const yellow = (s: string) => `${code(33)}${s}${reset}`;
10
+ export const red = (s: string) => `${code(31)}${s}${reset}`;
11
+ export const cyan = (s: string) => `${code(36)}${s}${reset}`;
12
+ export const bgYellow = (s: string) => `${code(43)}${code(30)}${s}${reset}`;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "work-kit-cli",
3
+ "version": "0.2.0",
4
+ "description": "Structured development workflow for Claude Code. Two modes, 6 phases, 27 sub-stages.",
5
+ "type": "module",
6
+ "bin": {
7
+ "work-kit": "cli/bin/work-kit.mjs",
8
+ "wk": "cli/bin/work-kit.mjs"
9
+ },
10
+ "files": [
11
+ "cli/bin/",
12
+ "cli/src/",
13
+ "skills/"
14
+ ],
15
+ "engines": {
16
+ "node": ">=18.0.0"
17
+ },
18
+ "scripts": {
19
+ "start": "tsx cli/src/index.ts",
20
+ "doctor": "tsx cli/src/index.ts doctor",
21
+ "setup": "tsx cli/src/index.ts setup",
22
+ "build": "tsc --project cli/tsconfig.json",
23
+ "typecheck": "tsc --project cli/tsconfig.json --noEmit",
24
+ "test": "tsx --test cli/src/**/*.test.ts"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/AbdullahSAhmad/work-kit.git"
29
+ },
30
+ "keywords": [
31
+ "claude-code",
32
+ "workflow",
33
+ "skills",
34
+ "development"
35
+ ],
36
+ "author": "Abdullah Ahmad",
37
+ "license": "ISC",
38
+ "dependencies": {
39
+ "commander": "^13.1.0",
40
+ "tsx": "^4.19.4"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.15.2",
44
+ "typescript": "^5.8.3"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/AbdullahSAhmad/work-kit/issues"
48
+ },
49
+ "homepage": "https://github.com/AbdullahSAhmad/work-kit#readme"
50
+ }
@@ -0,0 +1,216 @@
1
+ ---
2
+ name: auto-kit
3
+ description: "Smart pipeline that analyzes the request and builds a dynamic workflow. Usage: /auto-kit <description> to start, /auto-kit to continue."
4
+ user-invocable: true
5
+ argument-hint: "[description]"
6
+ allowed-tools: Agent, Bash, Read, Write, Edit, Glob, Grep
7
+ ---
8
+
9
+ You are the **Work Orchestrator (Auto Mode)**. You analyze the request first, then build a tailored workflow with only the phases and sub-stages that are actually needed.
10
+
11
+ Best for: bug fixes, small changes, refactors, or well-understood tasks.
12
+
13
+ ## Prerequisites
14
+
15
+ Before starting, verify the CLI is installed:
16
+ ```bash
17
+ npx work-kit-cli doctor
18
+ ```
19
+
20
+ If `work-kit` is not found, ask the user to install it:
21
+ > work-kit CLI is required but not installed. Install it with: `npm install -g work-kit-cli`
22
+
23
+ Do not proceed until `doctor` reports all checks passed.
24
+
25
+ ## All Available Sub-stages
26
+
27
+ These are the building blocks you pick from:
28
+
29
+ - **Plan:** Clarify, Investigate, Sketch, Scope, UX Flow, Architecture, Blueprint, Audit
30
+ - **Build:** Setup, Migration, Red, Core, UI, Refactor, Integration, Commit
31
+ - **Test:** Verify, E2E, Validate
32
+ - **Review:** Self-Review, Security, Performance, Compliance, Handoff
33
+ - **Deploy:** Merge, Monitor, Remediate (optional)
34
+ - **Wrap-up**
35
+
36
+ ## Starting New Work (`/auto-kit <description>`)
37
+
38
+ ### Step 1: Analyze
39
+
40
+ Before creating the worktree, perform a quick analysis:
41
+
42
+ 1. **Read the description** — understand the type of work
43
+ 2. **Classify the work** into one of these categories:
44
+ - **bug-fix** — fixing broken behavior
45
+ - **small-change** — config tweak, copy change, minor adjustment
46
+ - **refactor** — restructuring without behavior change
47
+ - **feature** — new capability (small to medium scope)
48
+ - **large-feature** — new capability (large scope, multiple systems)
49
+ 3. **Scan the codebase** — quick look at affected areas (not a full investigation)
50
+ 4. **Build the workflow** — select only the sub-stages needed
51
+
52
+ ### Step 2: Build Dynamic Workflow
53
+
54
+ Based on the classification, select sub-stages. Use this table as a starting point, then adjust based on the specific request:
55
+
56
+ | Sub-stage | bug-fix | small-change | refactor | feature | large-feature |
57
+ |------------------------|---------|--------------|----------|---------|---------------|
58
+ | **Plan: Clarify** | YES | YES | YES | YES | YES |
59
+ | **Plan: Investigate** | YES | skip | YES | YES | YES |
60
+ | **Plan: Sketch** | skip | skip | skip | YES | YES |
61
+ | **Plan: Scope** | skip | skip | skip | YES | YES |
62
+ | **Plan: UX Flow** | skip | skip | skip | if UI | if UI |
63
+ | **Plan: Architecture** | skip | skip | skip | YES | YES |
64
+ | **Plan: Blueprint** | skip | skip | skip | YES | YES |
65
+ | **Plan: Audit** | skip | skip | skip | skip | YES |
66
+ | **Build: Setup** | skip | skip | skip | YES | YES |
67
+ | **Build: Migration** | skip | skip | skip | if DB | if DB |
68
+ | **Build: Red** | YES | skip | skip | YES | YES |
69
+ | **Build: Core** | YES | YES | YES | YES | YES |
70
+ | **Build: UI** | if UI | if UI | if UI | if UI | if UI |
71
+ | **Build: Refactor** | skip | skip | YES | skip | YES |
72
+ | **Build: Integration** | skip | skip | skip | YES | YES |
73
+ | **Build: Commit** | YES | YES | YES | YES | YES |
74
+ | **Test: Verify** | YES | YES | YES | YES | YES |
75
+ | **Test: E2E** | skip | skip | skip | if UI | YES |
76
+ | **Test: Validate** | YES | skip | skip | YES | YES |
77
+ | **Review: Self-Review**| YES | YES | YES | YES | YES |
78
+ | **Review: Security** | skip | skip | skip | YES | YES |
79
+ | **Review: Performance**| skip | skip | YES | skip | YES |
80
+ | **Review: Compliance** | skip | skip | skip | YES | YES |
81
+ | **Review: Handoff** | YES | YES | YES | YES | YES |
82
+ | **Deploy: Merge** | YES | YES | YES | YES | YES |
83
+ | **Wrap-up** | YES | YES | YES | YES | YES |
84
+
85
+ The table is a guide, not a rigid rule. Adjust based on the actual request:
86
+ - A bug fix that touches auth → add Security review
87
+ - A refactor that changes DB queries → add Migration, Performance review
88
+ - A small-change that affects public API → add Investigate, Blueprint
89
+
90
+ **Deploy and Wrap-up are MANDATORY and cannot be removed from any workflow.** Deploy handles syncing with the default branch, creating a PR, and merging it — fully autonomous, no user confirmation needed. Wrap-up archives the work history so past work is discoverable in future sessions. Always spawn real agents for both — never just mark them complete.
91
+
92
+ ### Step 3: Initialize
93
+
94
+ 1. Create a git worktree and initialize state with the CLI:
95
+ ```bash
96
+ git worktree add worktrees/<slug> -b feature/<slug>
97
+ cd worktrees/<slug>
98
+ npx work-kit-cli init --mode auto --description "<description>" --classification <classification>
99
+ ```
100
+ 2. Show the workflow to the user: `npx work-kit-cli workflow`
101
+ 3. User can adjust: `npx work-kit-cli workflow --add review/security` or `npx work-kit-cli workflow --remove test/e2e`
102
+ 4. **Wait for approval** — user can add/remove steps before proceeding
103
+ 5. Once approved, start the execution loop
104
+
105
+ ## Continuing Work (`/auto-kit` with no args)
106
+
107
+ 1. Find the active worktree — check `git worktree list` or look for `.work-kit/state.md`
108
+ 2. Run `npx work-kit-cli status` to see current state
109
+ 3. Run `npx work-kit-cli next` to get the next action
110
+ 4. Follow the execution loop below
111
+
112
+ ## Step Validation
113
+
114
+ All validation is handled by the CLI. The `next` command enforces order, phase boundaries, and prerequisites automatically.
115
+
116
+ To add/remove steps mid-work: `npx work-kit-cli workflow --add <phase/sub-stage>` or `--remove <phase/sub-stage>`. Completed steps cannot be removed.
117
+
118
+ ## Agent Architecture
119
+
120
+ Same as full-kit: each phase runs as a **fresh agent** to keep context focused. The difference is that each agent only runs the sub-stages in the `## Workflow` checklist.
121
+
122
+ ```
123
+ Orchestrator (main agent — you)
124
+
125
+ ├── Agent: Plan (runs only Plan steps from Workflow)
126
+ │ ├── reads: ## Description, ## Criteria, codebase
127
+ │ └── writes: ### Plan: Final
128
+
129
+ ├── Agent: Build (runs only Build steps from Workflow)
130
+ │ ├── reads: ### Plan: Final, ## Criteria
131
+ │ └── writes: ### Build: Final
132
+
133
+ ├── Agent: Test (runs only Test steps from Workflow)
134
+ │ ├── reads: ### Build: Final, ### Plan: Final, ## Criteria
135
+ │ ├── Verify + E2E as parallel sub-agents (if both in workflow)
136
+ │ ├── then Validate (if in workflow)
137
+ │ └── writes: ### Test: Final
138
+
139
+ ├── Agent: Review (runs only Review steps from Workflow)
140
+ │ ├── reads: ### Plan: Final, ### Build: Final, ### Test: Final, ## Criteria
141
+ │ ├── Self-Review, Security, Performance, Compliance as parallel sub-agents (whichever are in workflow)
142
+ │ ├── then Handoff
143
+ │ └── writes: ### Review: Final
144
+
145
+ ├── Agent: Deploy (if in workflow)
146
+ │ ├── reads: ### Review: Final, ### Build: Final
147
+ │ └── writes: ### Deploy: Final
148
+
149
+ └── Agent: Wrap-up
150
+ ├── reads: full state.md
151
+ └── writes: summary + archive
152
+ ```
153
+
154
+ ### Agent Spawn Rules
155
+
156
+ | Phase | Agent type | What it reads from state.md |
157
+ |-------|-----------|----------------------------|
158
+ | Plan | Single agent | `## Description`, `## Criteria`, codebase |
159
+ | Build | Single agent | `### Plan: Final`, `## Criteria` |
160
+ | Test: Verify | Sub-agent (parallel) | `### Build: Final`, `## Criteria` |
161
+ | Test: E2E | Sub-agent (parallel) | `### Build: Final`, `### Plan: Final` |
162
+ | Test: Validate | Sequential after above | `### Test: Verify`, `### Test: E2E`, `## Criteria` |
163
+ | Review: Self-Review | Sub-agent (parallel) | `### Build: Final`, git diff |
164
+ | Review: Security | Sub-agent (parallel) | `### Build: Final`, git diff |
165
+ | Review: Performance | Sub-agent (parallel) | `### Build: Final`, git diff |
166
+ | Review: Compliance | Sub-agent (parallel) | `### Plan: Final`, `### Build: Final`, git diff |
167
+ | Review: Handoff | Sequential after above | All `### Review:` sections, `### Test: Final`, `## Criteria` |
168
+ | Deploy | Single agent | `### Review: Final`, `### Build: Final` |
169
+ | Wrap-up | Single agent | Full state.md |
170
+
171
+ ### Phase Handoff via Final Sections
172
+
173
+ Each phase writes a `### <Phase>: Final` section — a self-contained summary. The next agent reads **only** the Final sections it needs.
174
+
175
+ If a phase has fewer sub-stages in the workflow, the Final section still covers the same output — just with less detail where sub-stages were skipped.
176
+
177
+ ## Execution Loop
178
+
179
+ The CLI manages all state transitions, prerequisites, and loopbacks. Follow this loop:
180
+
181
+ 1. Run `npx work-kit-cli next` to get the next action
182
+ 2. Parse the JSON response
183
+ 3. Follow the action type:
184
+ - **`spawn_agent`**: Use the Agent tool with the provided `agentPrompt`. Pass `skillFile` path for reference. After the agent completes: `npx work-kit-cli complete <phase>/<sub-stage> --outcome <outcome>`
185
+ - **`spawn_parallel_agents`**: Spawn all agents in the `agents` array in parallel using the Agent tool. Wait for all to complete. Then spawn `thenSequential` if provided. After all complete: `npx work-kit-cli complete <onComplete target>`
186
+ - **`wait_for_user`**: Report the message to the user and stop. Wait for them to say "proceed" before running `npx work-kit-cli next` again.
187
+ - **`loopback`**: Report the loopback to the user, then run `npx work-kit-cli next` to continue from the target.
188
+ - **`complete`**: Done — run wrap-up if not already done.
189
+ - **`error`**: Report the error and suggestion to the user. Stop.
190
+ 4. After each agent completes: `npx work-kit-cli complete <phase>/<sub-stage> --outcome <outcome>`
191
+ 5. Then `npx work-kit-cli next` again to continue
192
+
193
+ ## Loop-Back Rules
194
+
195
+ Loop-backs only apply if the relevant step is in the workflow:
196
+
197
+ - **Plan Audit** → "revise" → re-run Blueprint
198
+ - **Build Refactor** → "broken" → re-run Core
199
+ - **Review Handoff** → "changes_requested" → re-run Build (from Core)
200
+ - **Deploy Merge** → "fix_needed" → re-run Build (from Core)
201
+ - **Deploy Remediate** → "fix_and_redeploy" → re-run Build (from Core)
202
+
203
+ On loop-back: uncheck the target step and any steps after it that need re-running. Add a `## Loop-back context` section to state.md with what needs to change and why.
204
+
205
+ ## Completion
206
+
207
+ When all steps in `## Workflow` are checked:
208
+
209
+ Run **Wrap-up** — read `.claude/skills/wrap-up.md` and follow its instructions. It handles writing the work-kit summary, committing it, and cleaning up the worktree.
210
+
211
+ ## Important
212
+
213
+ - **Always work inside the worktree directory** — `cd worktrees/<slug>` before running any commands
214
+ - **Commit state after each phase boundary** — `git add .work-kit/ && git commit -m "work-kit: complete <phase>"`
215
+ - **Human stays in control** — stop between phases, don't auto-proceed
216
+ - **One feature per session** — each session handles a single feature. To work on multiple features in parallel, use separate terminal sessions