crewkit 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.
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: full-workflow
3
+ description: "Execute the complete development workflow: classify size/risk, route to appropriate agents (explorer, architect, coder, tester, reviewer), validate in parallel, fix loop until clean."
4
+ ---
5
+
6
+ Execute the full orchestrator workflow for: $ARGUMENTS
7
+
8
+ ---
9
+
10
+ # Part 1 — Core Flow
11
+
12
+ ## Step 0 — Classify
13
+
14
+ > **Stack:** [detect from target files]
15
+ > **Size: SMALL / MEDIUM / LARGE**
16
+ > **Risk: LOW / MEDIUM / HIGH**
17
+ > Reason: [1 sentence for size, 1 sentence for risk]
18
+
19
+ | Size | Criteria |
20
+ |------|----------|
21
+ | **SMALL** | 1-2 files, localized change, scope is obvious, no cross-module impact |
22
+ | **MEDIUM** | 3-5 files, some cross-module dependencies, domain already known |
23
+ | **LARGE** | 6+ files, architectural impact, unknown codebase area, multi-module, or migration needed |
24
+
25
+ | Risk | Scope |
26
+ |------|-------|
27
+ | **LOW** | Pure DTO, mapper, UI without business logic, text, local refactor |
28
+ | **MEDIUM** | Application handlers, queries, validation, cache, UI with conditional logic |
29
+ | **HIGH** | Auth, multi-tenant, billing, permissions, deletes, migrations, background jobs, external integrations, public API contracts |
30
+
31
+ **Plan detection:** if `$ARGUMENTS` points to an existing `.ai/plans/*.md` file → skip explorer + architect, go straight to coder. Update plan status to IN_PROGRESS.
32
+
33
+ **Classification correction:** if later evidence shows the initial classification was too optimistic, immediately reclassify and switch to the appropriate flow.
34
+
35
+ ## Subagents
36
+
37
+ | Phase | Subagent | Model |
38
+ |-------|----------|-------|
39
+ | explorer | `explorer` | Sonnet |
40
+ | architect | `architect` | Opus |
41
+ | coder | `coder` | Sonnet |
42
+ | tester | `tester` | Sonnet |
43
+ | reviewer | `reviewer` | Opus |
44
+
45
+ ## Background execution rule
46
+
47
+ **When launching 2+ agents in parallel, ALWAYS use `run_in_background: true` on ALL of them.**
48
+
49
+ ---
50
+
51
+ ## Flows
52
+
53
+ ### SMALL
54
+
55
+ ```text
56
+ orchestrator → coder → [ tester | reviewer ] → consolidate → fix loop if needed
57
+ ```
58
+
59
+ 1. Read the target file(s) directly (no explorer scan)
60
+ 2. **coder** — implement smallest possible change
61
+ 3. **In parallel** (two Agent calls in the same message):
62
+ - **tester** — **Normal mode**: build, create tests, run full suite
63
+ - **reviewer** — review diff
64
+ 4. **Consolidate** (see Part 2)
65
+ 5. Clean → Summarize. Issues → fix loop.
66
+
67
+ ### MEDIUM
68
+
69
+ ```text
70
+ orchestrator → explorer → coder → [ tester | reviewer ] → consolidate → fix loop if needed
71
+ ```
72
+
73
+ 1. **explorer** — map relevant files and dependencies
74
+ 2. **coder** — implement based on explorer findings
75
+ 3. **In parallel**: tester (Normal mode) + reviewer
76
+ 4. Consolidate → Summarize or fix loop
77
+
78
+ ### LARGE — with plan
79
+
80
+ ```text
81
+ orchestrator → coder → [ tester | reviewer ] → consolidate → fix loop if needed
82
+ ```
83
+
84
+ 1. Read the plan file
85
+ 2. **coder** — implement per plan
86
+ 3. **In parallel**: tester (Normal mode) + reviewer
87
+ 4. Consolidate → Summarize or fix loop
88
+
89
+ ### LARGE — without plan
90
+
91
+ ```text
92
+ orchestrator → explorer → architect → [USER APPROVAL] → coder → [ tester | reviewer ] → consolidate → fix loop if needed
93
+ ```
94
+
95
+ 1. **explorer** — deep map
96
+ 2. **architect** — plan, assess risk
97
+ 3. **MANDATORY PAUSE** — present to user, wait for approval
98
+ 4. **coder** — implement per architect plan
99
+ 5. **In parallel**: tester + reviewer
100
+ 6. Consolidate → Summarize or fix loop
101
+
102
+ ---
103
+
104
+ ## Summarize (all flows)
105
+
106
+ Return:
107
+ - **Stack:** [detected]
108
+ - **Size:** SMALL / MEDIUM / LARGE
109
+ - **Risk:** LOW / MEDIUM / HIGH
110
+ - **Summary:** what was done
111
+ - **Files changed:** list
112
+ - **Tests:** X passed, Y failed
113
+ - **Review:** approved / needs changes
114
+ - **Risks / Next steps:** if any
115
+
116
+ If a plan file was used, update its status to **DONE**.
117
+
118
+ ## Memory Update
119
+
120
+ If a durable lesson was learned, append to the appropriate `lessons-{domain}.md`.
121
+
122
+ ---
123
+
124
+ # Part 2 — Operational Policies
125
+
126
+ ## Exit gate
127
+
128
+ **HARD BLOCK: No task is complete without reviewer APPROVED (clean).**
129
+
130
+ - Tester PASS alone is **not sufficient**
131
+ - Reviewer APPROVED is **mandatory** before Summarize
132
+ - **APPROVED with IMPORTANT+ findings is NOT clean.** Fix, then re-run tester + reviewer.
133
+ - Both must be clean (PASS + APPROVED without IMPORTANT+ findings) before Summarize.
134
+
135
+ ## Findings consolidation
136
+
137
+ After tester and reviewer finish:
138
+
139
+ 1. **Collect** results from both
140
+ 2. **Classify:** Tester = PASS/FAIL. Reviewer = APPROVED/NEEDS_CHANGES
141
+ 3. **Deduplicate** — same file + same concern → keep higher severity
142
+ 4. **APPROVED with IMPORTANT+ findings** = treat as NEEDS_CHANGES
143
+ 5. **Decision matrix:**
144
+
145
+ | Tester | Reviewer | Action |
146
+ |--------|----------|--------|
147
+ | PASS | APPROVED (clean) | Done → Summarize |
148
+ | PASS | APPROVED with IMPORTANT+ | Fix loop |
149
+ | PASS | NEEDS_CHANGES | Fix loop (reviewer findings) |
150
+ | FAIL | APPROVED | Fix loop (test failures) |
151
+ | FAIL | NEEDS_CHANGES | Fix loop (merge into ONE list for coder) |
152
+
153
+ When both fail, call coder **once** with the merged list.
154
+
155
+ ## Fix loop
156
+
157
+ 1. **Fix:**
158
+ - Risk **HIGH**: all fixes through **coder** — never auto-fix
159
+ - Risk LOW/MEDIUM: `auto_fixable: yes` → orchestrator applies directly. Else → coder
160
+ - When fix changes an exception type or interface → instruct coder to grep for all test doubles/fakes
161
+ 2. **Revalidate in parallel** (tester fix-loop mode + reviewer)
162
+ 3. Consolidate again
163
+ 4. Exit when PASS + APPROVED
164
+ 5. **Max 5 iterations** — then STOP and report to user.
165
+
166
+ **MINOR findings** do not trigger fix loop alone.
167
+
168
+ **Tester time budget:** if the tester reports pre-existing failures unrelated to the current task, the orchestrator must NOT ask the tester to fix them. Note them for a separate task and proceed.
169
+
170
+ ## Test creation rule
171
+
172
+ **Every behavioral change must be validated by tests.** The tester creates them automatically.
173
+
174
+ - New feature with logic → unit tests + integration when applicable
175
+ - Bug fix → test that reproduces the bug + verifies the fix
176
+ - Refactor with preserved behavior → existing tests are sufficient
177
+ - Cosmetic/text/DTO change without logic → build + review is sufficient
178
+
179
+ ## HIGH risk rules
180
+
181
+ - Never auto-fix — all through coder
182
+ - Full test suite on every revalidation
183
+ - Reviewer always mandatory
184
+ - Architect mandatory if any design decision is open
185
+
186
+ ## Stop conditions
187
+
188
+ STOP and escalate when:
189
+ - Build doesn't stabilize after 2 corrections
190
+ - Reviewer flags an architectural problem
191
+ - Tester finds widespread failures outside task scope
192
+ - Root cause unclear after 1 fix loop
193
+ - Affected files grow beyond plan
194
+ - SMALL/MEDIUM reveals structural impact
195
+
196
+ ---
197
+
198
+ # Part 3 — Stack Configuration
199
+
200
+ The orchestrator must tell subagents which build/test commands to use. Read `.ai/memory/commands.md` at the start and use the correct commands for each stack.
201
+
202
+ When telling the tester subagent what to do, always include:
203
+ - The stack being tested
204
+ - The test framework (from `.ai/memory/testing.md`)
205
+ - Whether this is a cross-stack task (requires testing multiple stacks)
206
+
207
+ For cross-stack tasks:
208
+ 1. Explorer maps both sides
209
+ 2. Architect evaluates the contract between stacks
210
+ 3. Coder runs once per stack in sequence (dependency direction decides order)
211
+ 4. Tester runs tests for all affected stacks
212
+ 5. Reviewer runs once across the full diff
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: hotfix
3
+ description: "Compressed workflow for urgent production fixes: diagnose → coder → [tester | reviewer] → consolidate → document. No refactor. No architecture phase unless the issue is not locally fixable."
4
+ ---
5
+
6
+ Execute hotfix for: $ARGUMENTS
7
+
8
+ ## When to use
9
+ Use only when production is broken and fast restoration matters more than broader improvement.
10
+
11
+ Skips explorer, architect, and refactor **only if**:
12
+ - the failure is already understood or can be confirmed quickly
13
+ - the fix is local
14
+ - no new architecture decision is required
15
+
16
+ If root cause is unclear, blast radius grows, or fix requires design trade-offs, **STOP and use `/full-workflow` instead**.
17
+
18
+ ## Never use hotfix for
19
+
20
+ These always require `/full-workflow`:
21
+ - **Auth or multi-tenant isolation** — wrong fix = data leak
22
+ - **Billing or payment logic** — wrong fix = financial impact
23
+ - **DB migrations** — irreversible in production
24
+ - **Public API contract changes** — breaks consumers
25
+ - **State machine transitions** — adding states affects the full lifecycle
26
+ - **Persistence format/schema changes** — wrong format corrupts state on restart
27
+ - **Retry/idempotency logic** — wrong fix = duplicates or lost events
28
+
29
+ Hotfix IS valid for:
30
+ - Guards/validations within existing flow
31
+ - Fixing a service call that sends wrong data
32
+ - Fixing a timer/job that isn't cleaned up
33
+ - Fixing an async handler that swallows errors
34
+ - Any localized fix that doesn't change the architecture
35
+
36
+ ---
37
+
38
+ ## Hotfix rules
39
+
40
+ - Restore service with the **smallest possible fix**
41
+ - No cleanup, no opportunistic refactor, no unrelated improvements
42
+ - Do not widen scope unless required for safety
43
+ - Every behavioral fix must be validated by tests
44
+
45
+ ---
46
+
47
+ ## Flow
48
+
49
+ ```text
50
+ orchestrator → diagnose → coder → [ tester | reviewer ] → consolidate → document
51
+ ```
52
+
53
+ ### Step 1 — Diagnose
54
+
55
+ Before calling coder, confirm the root cause. The orchestrator does this directly.
56
+
57
+ 1. Read the target file(s) and relevant logs/errors
58
+ 2. Run diagnostic commands (logs, DB queries, API calls, git blame)
59
+ 3. Identify the exact failure path
60
+ 4. State root cause in 1-2 sentences
61
+ 5. **Escape to `/full-workflow`** if:
62
+ - Root cause unclear after reading code + logs
63
+ - Fix requires 3+ files
64
+ - Fix requires migration, contract change, or infra change
65
+ - Fix requires architectural decision
66
+ - Fix touches auth, tenant isolation, or billing
67
+
68
+ ### Step 2 — Fix
69
+
70
+ Use **coder** with: confirmed root cause, target files, instruction for smallest fix.
71
+
72
+ ### Step 3 — Validate
73
+
74
+ **In parallel**: tester (Normal mode, full suite) + reviewer
75
+
76
+ ### Step 4 — Consolidate
77
+
78
+ | Tester | Reviewer | Action |
79
+ |--------|----------|--------|
80
+ | PASS | APPROVED | Done → Step 5 |
81
+ | PASS | NEEDS_CHANGES | Fix loop (1 max) |
82
+ | FAIL | APPROVED | Fix loop (1 max) |
83
+ | FAIL | NEEDS_CHANGES | Merge → fix loop (1 max) |
84
+
85
+ On fix loop iteration, revalidate **in parallel** (tester **Fix-loop mode** + reviewer), same as Step 3.
86
+
87
+ **Max 2 iterations.** If not clean → STOP and escalate to user with:
88
+ - Summary of what was attempted and why it failed
89
+ - Recommend: **revert** (if fix introduced worse regressions) or **escalate to `/full-workflow`** (if fix is on right track but needs more work)
90
+ - Never leave broken code uncommitted — either revert to last known good state or commit with `[WIP]` marker and explain what remains
91
+
92
+ ### Step 5 — Document
93
+
94
+ Append to appropriate `lessons-{domain}.md`:
95
+
96
+ ```markdown
97
+ ### [YYYY-MM-DD] Hotfix: <short title>
98
+ - **Root cause:** [1-2 sentences]
99
+ - **Fix:** [what was changed]
100
+ - **Files:** [list]
101
+ - **Lesson:** [what to watch for to prevent recurrence]
102
+ ```
103
+
104
+ **Follow-up assessment:** If root cause reveals systemic issue, suggest `/explore-and-plan` for structural fix.
105
+
106
+ ---
107
+
108
+ ## Return Format
109
+
110
+ - **Stack:** [detected]
111
+ - **Root cause:** [1-2 sentences]
112
+ - **Summary:** what was fixed
113
+ - **Files changed:** list
114
+ - **Tests:** X passed, Y failed
115
+ - **Review:** approved / needs changes
116
+ - **Lesson documented:** yes/no
117
+ - **Residual risks:** [if any]
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: review-pr
3
+ description: "Review a pull request using the reviewer agent. Fetches diff + description via gh CLI, returns structured findings."
4
+ ---
5
+
6
+ Review pull request: $ARGUMENTS
7
+
8
+ ## Steps
9
+
10
+ ### 1. Fetch PR data
11
+
12
+ Run in parallel:
13
+ ```bash
14
+ gh pr view $ARGUMENTS --json number,title,body,author,baseRefName,headRefName,additions,deletions,changedFiles
15
+ gh pr diff $ARGUMENTS
16
+ ```
17
+
18
+ If $ARGUMENTS is empty, use `gh pr view` (current branch's PR).
19
+
20
+ ### 2. Load project context
21
+
22
+ Read `.ai/memory/architecture.md` and `.ai/memory/conventions.md`.
23
+
24
+ ### 3. Run reviewer agent
25
+
26
+ Pass to **reviewer** subagent:
27
+ - Full PR diff
28
+ - PR title and description
29
+ - File count and change size
30
+ - Project context from step 2
31
+
32
+ The reviewer applies all checks from its instructions and `.ai/memory/conventions.md`, including project-specific rules (e.g., multi-tenant enforcement, architecture layer violations, forbidden patterns).
33
+
34
+ ### 4. Return
35
+
36
+ ```markdown
37
+ ---
38
+ **PR #[number] — [title]**
39
+ **Author:** [author] | **Branch:** [head] → [base]
40
+ **Size:** +[additions] / -[deletions] in [changedFiles] files
41
+
42
+ **Findings:**
43
+ - CRITICAL: [list or "none"]
44
+ - IMPORTANT: [list or "none"]
45
+ - MINOR: [list or "none"]
46
+
47
+ **Positives:** [what's good]
48
+
49
+ **Verdict:** APPROVED / NEEDS_CHANGES
50
+ ---
51
+ ```
52
+
53
+ If no PR number provided and no current branch PR exists, ask for the PR number.
package/src/cli.js ADDED
@@ -0,0 +1,35 @@
1
+ import { install } from './install.js';
2
+
3
+ const HELP = `
4
+ crewkit — Context engineering for AI-assisted development
5
+
6
+ Commands:
7
+ install Install crewkit skill globally (~/.claude/skills/)
8
+ update Update to latest version (re-run install)
9
+ help Show this message
10
+
11
+ Usage:
12
+ npx crewkit install # one-time setup
13
+ /crewkit-setup # run in your IDE to scan & calibrate a project
14
+ `;
15
+
16
+ export function run(args) {
17
+ const command = args[0];
18
+
19
+ switch (command) {
20
+ case 'install':
21
+ case 'update':
22
+ install();
23
+ break;
24
+ case 'help':
25
+ case '--help':
26
+ case '-h':
27
+ case undefined:
28
+ console.log(HELP);
29
+ break;
30
+ default:
31
+ console.error(`Unknown command: ${command}`);
32
+ console.log(HELP);
33
+ process.exit(1);
34
+ }
35
+ }
package/src/install.js ADDED
@@ -0,0 +1,40 @@
1
+ import { cpSync, mkdirSync, existsSync, readFileSync } from 'node:fs';
2
+ import { join, dirname } from 'node:path';
3
+ import { homedir } from 'node:os';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+
9
+ export function install() {
10
+ const skillSource = join(__dirname, '..', 'skill');
11
+ const skillDest = join(homedir(), '.claude', 'skills', 'crewkit-setup');
12
+
13
+ // Verify source exists
14
+ if (!existsSync(skillSource)) {
15
+ console.error('Error: skill/ directory not found. Package may be corrupted.');
16
+ process.exit(1);
17
+ }
18
+
19
+ // Create destination
20
+ mkdirSync(skillDest, { recursive: true });
21
+
22
+ // Copy skill + templates
23
+ cpSync(skillSource, skillDest, { recursive: true, force: true });
24
+
25
+ // Read version
26
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
27
+
28
+ console.log(`
29
+ ✓ crewkit v${pkg.version} installed
30
+
31
+ Skill copied to: ${skillDest}
32
+
33
+ Next: open any project in Claude Code and run:
34
+
35
+ /crewkit-setup
36
+
37
+ This will scan your codebase and generate a complete
38
+ context engineering setup (agents, skills, hooks, rules, memory).
39
+ `);
40
+ }