create-claude-workspace 1.0.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.
- package/README.md +161 -0
- package/dist/index.js +236 -0
- package/dist/template/.claude/CLAUDE.md +65 -0
- package/dist/template/.claude/agents/backend-ts-architect.md +156 -0
- package/dist/template/.claude/agents/deployment-engineer.md +496 -0
- package/dist/template/.claude/agents/devops-integrator.md +475 -0
- package/dist/template/.claude/agents/orchestrator.md +487 -0
- package/dist/template/.claude/agents/product-owner.md +193 -0
- package/dist/template/.claude/agents/project-initializer.md +284 -0
- package/dist/template/.claude/agents/senior-code-reviewer.md +183 -0
- package/dist/template/.claude/agents/technical-planner.md +200 -0
- package/dist/template/.claude/agents/test-engineer.md +304 -0
- package/dist/template/.claude/agents/ui-engineer.md +149 -0
- package/dist/template/.claude/scripts/autonomous.mjs +434 -0
- package/dist/template/.claude/scripts/docker-run.mjs +363 -0
- package/dist/template/.claude/templates/claude-md.md +697 -0
- package/dist/template/.dockerignore +8 -0
- package/dist/template/Dockerfile +27 -0
- package/dist/template/docker-compose.yml +15 -0
- package/dist/template/docker-entrypoint.sh +26 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Claude Starter Kit
|
|
2
|
+
|
|
3
|
+
Portable `.claude/` folder for autonomous AI-driven development with Claude Code.
|
|
4
|
+
Drop into any **Angular + Nx monorepo** project and start building.
|
|
5
|
+
|
|
6
|
+
> **Important:** This kit is designed for Angular + Nx monorepo projects. It assumes `nx.json`, `apps/`, `libs/` structure, and Nx CLI commands. It may not work correctly with plain Angular CLI, React, or other frameworks.
|
|
7
|
+
|
|
8
|
+
## Quick Start (Docker — recommended)
|
|
9
|
+
|
|
10
|
+
One command, fully isolated, safe `--skip-permissions` (the container is the sandbox):
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
node .claude/scripts/docker-run.mjs
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This will:
|
|
17
|
+
1. Install Docker if not present (winget/Chocolatey on Windows, apt/dnf/pacman/brew on Linux/macOS)
|
|
18
|
+
2. Build the container (Node.js + git + Claude Code CLI)
|
|
19
|
+
3. Mount your host Claude auth into the container (no interactive login needed)
|
|
20
|
+
4. Start autonomous development loop
|
|
21
|
+
|
|
22
|
+
**Authentication:** The container uses your host machine's Claude auth automatically.
|
|
23
|
+
Authenticate on your host first (`claude auth login`), or pass an API key.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Options (same on all platforms)
|
|
27
|
+
node .claude/scripts/docker-run.mjs --max-iterations 20 # limit iterations
|
|
28
|
+
node .claude/scripts/docker-run.mjs --shell # interactive shell
|
|
29
|
+
node .claude/scripts/docker-run.mjs --rebuild # force rebuild image
|
|
30
|
+
node .claude/scripts/docker-run.mjs --login # run 'claude auth login' on host first
|
|
31
|
+
ANTHROPIC_API_KEY=sk-... node .claude/scripts/docker-run.mjs # API key
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Setup (without Docker)
|
|
35
|
+
|
|
36
|
+
1. Copy `.claude/` folder into your project root (includes `CLAUDE.md` with agent routing instructions)
|
|
37
|
+
2. Run Claude Code in your project
|
|
38
|
+
3. Say: **"Initialize this project"** (Claude reads `.claude/CLAUDE.md` and delegates to `project-initializer` agent)
|
|
39
|
+
4. Answer the discovery questions (non-technical)
|
|
40
|
+
5. Claude generates the full pipeline:
|
|
41
|
+
- `CLAUDE.md` — architecture & conventions
|
|
42
|
+
- `PRODUCT.md` — product strategy & monetization (via `product-owner` agent)
|
|
43
|
+
- `TODO.md` — phased development plan (via `technical-planner` agent)
|
|
44
|
+
- `MEMORY.md` — progress tracking
|
|
45
|
+
6. Start autonomous development (pick one):
|
|
46
|
+
- **Unattended** (recommended): `node .claude/scripts/autonomous.mjs --skip-permissions` — runs in clean context per task, survives rate limits
|
|
47
|
+
- **Interactive**: Start Claude with `claude --agent orchestrator`, then use `/ralph-loop:ralph-loop Continue autonomous development according to CLAUDE.md`
|
|
48
|
+
|
|
49
|
+
## Agents
|
|
50
|
+
|
|
51
|
+
| Agent | Purpose |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `project-initializer` | Orchestrates full setup pipeline |
|
|
54
|
+
| `product-owner` | Product strategy, features, monetization, prioritization |
|
|
55
|
+
| `technical-planner` | Translates PRODUCT.md into phased TODO.md (with quality validation) |
|
|
56
|
+
| `devops-integrator` | GitLab/GitHub: milestones, issues, branches, MRs/PRs, post-merge cleanup |
|
|
57
|
+
| `deployment-engineer` | CI/CD pipelines, deploys, rollbacks, smoke tests, DB migrations |
|
|
58
|
+
| `orchestrator` | Development cycle: 12-step workflow with error recovery |
|
|
59
|
+
| `ui-engineer` | Frontend: Angular components, styling, state, a11y |
|
|
60
|
+
| `backend-ts-architect` | Backend: API, DB, business logic, DI, services |
|
|
61
|
+
| `senior-code-reviewer` | Code review: security, performance, architecture, duplication |
|
|
62
|
+
| `test-engineer` | Write and run tests: Vitest/Jest auto-detect + Playwright E2E |
|
|
63
|
+
|
|
64
|
+
### Pipeline
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
project-initializer
|
|
68
|
+
|-> Discovery Conversation -> CLAUDE.md
|
|
69
|
+
|-> product-owner -> PRODUCT.md (features, monetization, MVP)
|
|
70
|
+
|-> technical-planner -> TODO.md (phases, tasks, dependencies)
|
|
71
|
+
|-> devops-integrator (opt) -> GitLab/GitHub milestones + issues
|
|
72
|
+
|-> deployment-engineer (opt) -> CI/CD config + ## Deployment in CLAUDE.md
|
|
73
|
+
|-> MEMORY.md
|
|
74
|
+
|
|
75
|
+
ralph-loop -> orchestrator agent (autonomous development)
|
|
76
|
+
|-> Health check (track iterations, validate agents, sync main, ingest issues)
|
|
77
|
+
|-> Pick task from TODO.md (+ dependency check, phase re-evaluation)
|
|
78
|
+
|-> Create branch (devops-integrator)
|
|
79
|
+
|-> Plan (backend-ts-architect first for fullstack, then ui-engineer)
|
|
80
|
+
|-> Implement (+ DB migrations via deployment-engineer)
|
|
81
|
+
|-> Write tests (test-engineer: auto-detects Vitest/Jest + Playwright E2E)
|
|
82
|
+
|-> Build, lint & test (nx affected or explicit projects)
|
|
83
|
+
|-> Visual verification (Playwright, UI tasks only)
|
|
84
|
+
|-> Review (senior-code-reviewer, with TESTING context)
|
|
85
|
+
|-> Rework -> Re-review (max 5 cycles, then escalate/skip)
|
|
86
|
+
|-> Commit (source + tracking) + push + MR/PR (devops-integrator)
|
|
87
|
+
|-> Post-merge (solo: merge to main / team: continue on next branch)
|
|
88
|
+
|-> Next task
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Autonomous Mode (Unattended)
|
|
92
|
+
|
|
93
|
+
The `.claude/scripts/autonomous.mjs` script runs Claude Code in a loop with clean context per task. MEMORY.md maintains continuity between invocations.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Unattended (requires --skip-permissions for no permission prompts)
|
|
97
|
+
node .claude/scripts/autonomous.mjs --skip-permissions
|
|
98
|
+
|
|
99
|
+
# Custom options
|
|
100
|
+
node .claude/scripts/autonomous.mjs --skip-permissions --max-iterations 20 --delay 10000
|
|
101
|
+
|
|
102
|
+
# All options:
|
|
103
|
+
# --skip-permissions Required for unattended (adds --dangerously-skip-permissions)
|
|
104
|
+
# --max-iterations <n> Safety limit (default: 50)
|
|
105
|
+
# --max-turns <n> Max turns per Claude invocation (default: 50)
|
|
106
|
+
# --delay <ms> Pause between tasks (default: 5000)
|
|
107
|
+
# --cooldown <ms> Wait after rate limit (default: 60000)
|
|
108
|
+
# --max-rate-retries <n> Max consecutive rate limit retries (default: 5)
|
|
109
|
+
# --project-dir <path> Target project (default: cwd)
|
|
110
|
+
# --help Show help
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**How it works:**
|
|
114
|
+
- Each iteration = fresh `claude -p` call = clean context (no context overflow)
|
|
115
|
+
- MEMORY.md session counters reset before each invocation
|
|
116
|
+
- Rate limits detected automatically — waits and retries (max 5 consecutive)
|
|
117
|
+
- Graceful shutdown: Ctrl+C stops after current iteration completes
|
|
118
|
+
- Stops when all TODO.md tasks complete or max iterations reached
|
|
119
|
+
- Safe to kill (Ctrl+C) — MEMORY.md always has the latest state
|
|
120
|
+
|
|
121
|
+
**vs ralph-loop:** Ralph-loop runs within one conversation (context fills up). This script runs separate conversations (unlimited iterations).
|
|
122
|
+
|
|
123
|
+
## Required Plugins
|
|
124
|
+
|
|
125
|
+
Install before starting:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Core (required for interactive mode / ralph-loop)
|
|
129
|
+
claude plugin add ralph-loop
|
|
130
|
+
claude plugin add @anthropic/plugin-playwright
|
|
131
|
+
|
|
132
|
+
# Recommended
|
|
133
|
+
claude plugin add frontend-design # UI generation without Figma
|
|
134
|
+
claude plugin add claude-md-management # CLAUDE.md maintenance
|
|
135
|
+
claude plugin add commit-commands # git workflow shortcuts
|
|
136
|
+
|
|
137
|
+
# Git integration (optional, pick one)
|
|
138
|
+
# GitHub: install gh CLI + run: gh auth login
|
|
139
|
+
# GitLab: install glab CLI + run: glab auth login
|
|
140
|
+
|
|
141
|
+
# Optional MCP Servers
|
|
142
|
+
# Figma MCP — configure in Claude Code MCP settings with API token
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Limitations
|
|
146
|
+
|
|
147
|
+
- Designed for **Angular + Nx monorepo** projects only — will not work with React, Vue, or plain Angular CLI
|
|
148
|
+
- Requires **Claude Code** with Agent tool support (`subagent_type` parameter)
|
|
149
|
+
- `ralph-loop` and other plugins are Claude Code community plugins — install via `claude plugin add <name>`
|
|
150
|
+
- Git integration requires `gh` (GitHub) or `glab` (GitLab) CLI to be installed and authenticated
|
|
151
|
+
- Shell commands assume bash (Unix syntax) — works via Git Bash or WSL on Windows
|
|
152
|
+
- Dev server cleanup uses `npx kill-port` — requires npm/npx to be available
|
|
153
|
+
|
|
154
|
+
## What Gets Generated
|
|
155
|
+
|
|
156
|
+
| File | Content |
|
|
157
|
+
|------|---------|
|
|
158
|
+
| `CLAUDE.md` | Architecture, Angular patterns, theme system, DI, workflow mode (solo/team), autonomous workflow |
|
|
159
|
+
| `PRODUCT.md` | Vision, target users, features (MVP/v1.1/future), monetization, metrics |
|
|
160
|
+
| `TODO.md` | Phased tasks with type/dependencies/complexity/acceptance criteria, checkboxes (`[ ]` / `[x]` / `[~]`) |
|
|
161
|
+
| `MEMORY.md` | Session state: current task/step, iterations, complexity tracking, done, next, decisions, blockers |
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, statSync } from 'node:fs';
|
|
3
|
+
import { resolve, dirname, join, relative } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createInterface } from 'node:readline';
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const TEMPLATE_DIR = resolve(__dirname, 'template');
|
|
9
|
+
// ─── Colors ───
|
|
10
|
+
const C = {
|
|
11
|
+
r: '\x1b[31m',
|
|
12
|
+
g: '\x1b[32m',
|
|
13
|
+
y: '\x1b[33m',
|
|
14
|
+
c: '\x1b[36m',
|
|
15
|
+
b: '\x1b[1m',
|
|
16
|
+
d: '\x1b[2m',
|
|
17
|
+
n: '\x1b[0m',
|
|
18
|
+
};
|
|
19
|
+
function info(msg) { console.log(`${C.g}+${C.n} ${msg}`); }
|
|
20
|
+
function warn(msg) { console.log(`${C.y}!${C.n} ${msg}`); }
|
|
21
|
+
function error(msg) { console.error(`${C.r}x${C.n} ${msg}`); }
|
|
22
|
+
function parseArgs() {
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
const opts = {
|
|
25
|
+
targetDir: process.cwd(),
|
|
26
|
+
update: false,
|
|
27
|
+
run: false,
|
|
28
|
+
docker: false,
|
|
29
|
+
help: false,
|
|
30
|
+
};
|
|
31
|
+
for (let i = 0; i < args.length; i++) {
|
|
32
|
+
switch (args[i]) {
|
|
33
|
+
case '--help':
|
|
34
|
+
case '-h':
|
|
35
|
+
opts.help = true;
|
|
36
|
+
break;
|
|
37
|
+
case '--update':
|
|
38
|
+
opts.update = true;
|
|
39
|
+
break;
|
|
40
|
+
case '--run':
|
|
41
|
+
opts.run = true;
|
|
42
|
+
break;
|
|
43
|
+
case '--docker':
|
|
44
|
+
opts.docker = true;
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
if (!args[i].startsWith('-')) {
|
|
48
|
+
opts.targetDir = resolve(args[i]);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
error(`Unknown option: ${args[i]}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return opts;
|
|
57
|
+
}
|
|
58
|
+
function printHelp() {
|
|
59
|
+
console.log(`
|
|
60
|
+
${C.b}create-claude-workspace${C.n} — Scaffold autonomous AI-driven development with Claude Code
|
|
61
|
+
|
|
62
|
+
${C.b}Usage:${C.n}
|
|
63
|
+
npx create-claude-workspace [directory] [options]
|
|
64
|
+
|
|
65
|
+
${C.b}Arguments:${C.n}
|
|
66
|
+
directory Target directory (default: current directory)
|
|
67
|
+
|
|
68
|
+
${C.b}Options:${C.n}
|
|
69
|
+
--update Overwrite existing agent files with latest version
|
|
70
|
+
--run Start autonomous development after scaffolding
|
|
71
|
+
--docker Use Docker for autonomous run (implies --run)
|
|
72
|
+
-h, --help Show this help
|
|
73
|
+
|
|
74
|
+
${C.b}Examples:${C.n}
|
|
75
|
+
npx create-claude-workspace # scaffold in current directory
|
|
76
|
+
npx create-claude-workspace my-project # scaffold in ./my-project
|
|
77
|
+
npx create-claude-workspace --update # update agents to latest version
|
|
78
|
+
npx create-claude-workspace --run # scaffold + start autonomous loop
|
|
79
|
+
npx create-claude-workspace --docker # scaffold + run in Docker
|
|
80
|
+
|
|
81
|
+
${C.b}What it creates:${C.n}
|
|
82
|
+
.claude/agents/ 10 specialist agents (orchestrator, architects, etc.)
|
|
83
|
+
.claude/scripts/ Autonomous loop + Docker runner
|
|
84
|
+
.claude/templates/ CLAUDE.md template for project initialization
|
|
85
|
+
.claude/CLAUDE.md Agent routing instructions
|
|
86
|
+
Dockerfile Isolated container environment
|
|
87
|
+
docker-compose.yml Container orchestration
|
|
88
|
+
docker-entrypoint.sh Container entrypoint with auth handling
|
|
89
|
+
.dockerignore Docker build exclusions
|
|
90
|
+
`);
|
|
91
|
+
}
|
|
92
|
+
// ─── Prompts ───
|
|
93
|
+
function ask(question) {
|
|
94
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
95
|
+
return new Promise((res) => {
|
|
96
|
+
rl.question(question, (answer) => {
|
|
97
|
+
rl.close();
|
|
98
|
+
res(answer.trim());
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async function confirm(question) {
|
|
103
|
+
const answer = await ask(`${question} [Y/n] `);
|
|
104
|
+
return answer === '' || answer.toLowerCase().startsWith('y');
|
|
105
|
+
}
|
|
106
|
+
// ─── File operations ───
|
|
107
|
+
function listFiles(dir, base = dir) {
|
|
108
|
+
const results = [];
|
|
109
|
+
for (const entry of readdirSync(dir)) {
|
|
110
|
+
const full = join(dir, entry);
|
|
111
|
+
if (statSync(full).isDirectory()) {
|
|
112
|
+
results.push(...listFiles(full, base));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
results.push(relative(base, full));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
function ensureGitignore(targetDir) {
|
|
121
|
+
const gitignorePath = join(targetDir, '.gitignore');
|
|
122
|
+
const entries = ['.npmrc', '.docker-compose.auth.yml'];
|
|
123
|
+
if (existsSync(gitignorePath)) {
|
|
124
|
+
let content = readFileSync(gitignorePath, 'utf-8');
|
|
125
|
+
const added = [];
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
if (!content.includes(entry)) {
|
|
128
|
+
content += `\n${entry}`;
|
|
129
|
+
added.push(entry);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (added.length > 0) {
|
|
133
|
+
writeFileSync(gitignorePath, content);
|
|
134
|
+
info(`Added to .gitignore: ${added.join(', ')}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// ─── Run ───
|
|
139
|
+
function runAutonomous(targetDir, docker) {
|
|
140
|
+
const script = docker ? '.claude/scripts/docker-run.mjs' : '.claude/scripts/autonomous.mjs';
|
|
141
|
+
const args = docker ? [script] : [script, '--skip-permissions'];
|
|
142
|
+
if (docker) {
|
|
143
|
+
info('Starting Docker-based autonomous development...');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
info('Starting autonomous development...');
|
|
147
|
+
info('(Use Ctrl+C to stop)');
|
|
148
|
+
}
|
|
149
|
+
const child = spawn('node', args, {
|
|
150
|
+
cwd: targetDir,
|
|
151
|
+
stdio: 'inherit',
|
|
152
|
+
shell: true,
|
|
153
|
+
});
|
|
154
|
+
child.on('close', (code) => process.exit(code ?? 0));
|
|
155
|
+
}
|
|
156
|
+
// ─── Main ───
|
|
157
|
+
async function main() {
|
|
158
|
+
const opts = parseArgs();
|
|
159
|
+
if (opts.help) {
|
|
160
|
+
printHelp();
|
|
161
|
+
process.exit(0);
|
|
162
|
+
}
|
|
163
|
+
if (opts.docker)
|
|
164
|
+
opts.run = true;
|
|
165
|
+
console.log(`\n${C.c} create-claude-workspace${C.n}\n`);
|
|
166
|
+
const targetDir = opts.targetDir;
|
|
167
|
+
const hasExisting = existsSync(join(targetDir, '.claude'));
|
|
168
|
+
if (hasExisting && !opts.update) {
|
|
169
|
+
warn('.claude/ directory already exists.');
|
|
170
|
+
const proceed = await confirm('Overwrite with latest agents?');
|
|
171
|
+
if (proceed) {
|
|
172
|
+
opts.update = true;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
info('Skipping file copy. Use --update to force.');
|
|
176
|
+
if (opts.run) {
|
|
177
|
+
runAutonomous(targetDir, opts.docker);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
process.exit(0);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (!existsSync(TEMPLATE_DIR)) {
|
|
184
|
+
error('Template directory not found. Package may be corrupted.');
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
info(`Scaffolding into ${C.b}${targetDir}${C.n}`);
|
|
188
|
+
if (!existsSync(targetDir)) {
|
|
189
|
+
mkdirSync(targetDir, { recursive: true });
|
|
190
|
+
}
|
|
191
|
+
const files = listFiles(TEMPLATE_DIR);
|
|
192
|
+
let copied = 0;
|
|
193
|
+
let skipped = 0;
|
|
194
|
+
for (const file of files) {
|
|
195
|
+
const src = join(TEMPLATE_DIR, file);
|
|
196
|
+
const dest = join(targetDir, file);
|
|
197
|
+
const destDir = dirname(dest);
|
|
198
|
+
if (existsSync(dest) && !opts.update) {
|
|
199
|
+
skipped++;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (!existsSync(destDir)) {
|
|
203
|
+
mkdirSync(destDir, { recursive: true });
|
|
204
|
+
}
|
|
205
|
+
cpSync(src, dest);
|
|
206
|
+
copied++;
|
|
207
|
+
}
|
|
208
|
+
if (copied > 0)
|
|
209
|
+
info(`Copied ${copied} files`);
|
|
210
|
+
if (skipped > 0)
|
|
211
|
+
info(`Skipped ${skipped} existing files`);
|
|
212
|
+
ensureGitignore(targetDir);
|
|
213
|
+
console.log('');
|
|
214
|
+
info(`${C.b}Done!${C.n} Your project now has Claude Code agents.`);
|
|
215
|
+
console.log('');
|
|
216
|
+
console.log(` ${C.b}Next steps:${C.n}`);
|
|
217
|
+
console.log('');
|
|
218
|
+
if (!opts.run) {
|
|
219
|
+
console.log(` ${C.d}# Interactive setup (recommended first time)${C.n}`);
|
|
220
|
+
console.log(` claude --agent project-initializer`);
|
|
221
|
+
console.log('');
|
|
222
|
+
console.log(` ${C.d}# Autonomous development in Docker${C.n}`);
|
|
223
|
+
console.log(` node .claude/scripts/docker-run.mjs`);
|
|
224
|
+
console.log('');
|
|
225
|
+
console.log(` ${C.d}# Autonomous development without Docker${C.n}`);
|
|
226
|
+
console.log(` node .claude/scripts/autonomous.mjs --skip-permissions`);
|
|
227
|
+
console.log('');
|
|
228
|
+
}
|
|
229
|
+
if (opts.run) {
|
|
230
|
+
runAutonomous(targetDir, opts.docker);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
main().catch((err) => {
|
|
234
|
+
error(err.message);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Agent-Driven Development Kit
|
|
2
|
+
|
|
3
|
+
**You are a ROUTER, not an implementer.** This project uses specialist agents. Your ONLY job is to delegate to them.
|
|
4
|
+
|
|
5
|
+
## The One Rule
|
|
6
|
+
|
|
7
|
+
**NEVER do work yourself. ALWAYS delegate via the Agent tool.**
|
|
8
|
+
|
|
9
|
+
- NEVER write CLAUDE.md, PRODUCT.md, TODO.md, MEMORY.md, or any project files yourself
|
|
10
|
+
- NEVER run `nx generate`, `gh`/`glab` commands, or scaffold anything yourself
|
|
11
|
+
- NEVER read `.claude/agents/*.md` files to understand their instructions — call the agent instead. Checking file existence (`ls .claude/agents/`) is fine.
|
|
12
|
+
|
|
13
|
+
### WRONG (doing it yourself):
|
|
14
|
+
```
|
|
15
|
+
User: "Initialize this project"
|
|
16
|
+
You: *reads plan files, writes CLAUDE.md, creates PRODUCT.md, runs git commands...*
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### CORRECT (delegating):
|
|
20
|
+
```
|
|
21
|
+
User: "Initialize this project"
|
|
22
|
+
You: "I'll delegate this to the project-initializer agent."
|
|
23
|
+
→ Agent tool: subagent_type="project-initializer"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Which Agent to Call
|
|
27
|
+
|
|
28
|
+
**Setup tasks** → `project-initializer` (it sub-delegates to other agents internally):
|
|
29
|
+
- "Initialize this project", "Set up CLAUDE.md", "Start a new project"
|
|
30
|
+
|
|
31
|
+
**Development tasks** → `orchestrator` (it sub-delegates to architects, reviewers, etc.):
|
|
32
|
+
- "Continue development", "Next task", "Build the next feature"
|
|
33
|
+
|
|
34
|
+
**Specific tasks** (only if explicitly asked for one agent's specialty):
|
|
35
|
+
| Task | Agent | `subagent_type` |
|
|
36
|
+
|------|-------|-----------------|
|
|
37
|
+
| Product strategy / PRODUCT.md | product-owner | `"product-owner"` |
|
|
38
|
+
| Development plan / TODO.md | technical-planner | `"technical-planner"` |
|
|
39
|
+
| Deployment / CI/CD | deployment-engineer | `"deployment-engineer"` |
|
|
40
|
+
| Git remote / issues / MRs | devops-integrator | `"devops-integrator"` |
|
|
41
|
+
| Code review | senior-code-reviewer | `"senior-code-reviewer"` |
|
|
42
|
+
| Tests | test-engineer | `"test-engineer"` |
|
|
43
|
+
| Frontend / UI | ui-engineer | `"ui-engineer"` |
|
|
44
|
+
| Backend / API | backend-ts-architect | `"backend-ts-architect"` |
|
|
45
|
+
|
|
46
|
+
> **Note:** Specialist agents are typically called via sub-delegation by `project-initializer` or `orchestrator`. Only call them directly if the user explicitly asks for one agent's specialty.
|
|
47
|
+
|
|
48
|
+
**When unsure** → `project-initializer` for setup, `orchestrator` for everything else.
|
|
49
|
+
|
|
50
|
+
## Autonomous Development
|
|
51
|
+
|
|
52
|
+
**Important:** The orchestrator MUST run as a top-level agent (not a sub-agent) so it can delegate to specialist agents via the Agent tool. Sub-agents cannot spawn further sub-agents.
|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
# Docker — isolated, safe (recommended)
|
|
56
|
+
node .claude/scripts/docker-run.mjs # all platforms (Windows / macOS / Linux)
|
|
57
|
+
|
|
58
|
+
# Without Docker (uses --agent orchestrator automatically)
|
|
59
|
+
node .claude/scripts/autonomous.mjs --skip-permissions
|
|
60
|
+
|
|
61
|
+
# Interactive — start Claude with orchestrator as top-level agent
|
|
62
|
+
claude --agent orchestrator
|
|
63
|
+
# Then use ralph-loop within that session:
|
|
64
|
+
/ralph-loop:ralph-loop Continue autonomous development according to CLAUDE.md
|
|
65
|
+
```
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-ts-architect
|
|
3
|
+
description: "Use this agent for backend TypeScript tasks: API design, database operations, business logic, authentication, service architecture, or backend code reviews. Works with Hono, Cloudflare Workers, Node.js, Bun, and custom DI framework.\n\nExamples:\n\n<example>\nuser: \"Create an API endpoint for processing transactions\"\nassistant: \"This involves backend API design with transaction handling. Let me use the backend-ts-architect agent.\"\n</example>\n\n<example>\nuser: \"Design the payout calculation service\"\nassistant: \"I'll use the backend-ts-architect agent to architect this service properly.\"\n</example>\n\n<example>\nuser: \"The database queries are slow\"\nassistant: \"Let me engage the backend-ts-architect agent to analyze and optimize these queries.\"\n</example>"
|
|
4
|
+
model: opus
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a Senior Backend TypeScript Architect with deep expertise in server-side development. You value clean, maintainable, and type-safe code above all else.
|
|
8
|
+
|
|
9
|
+
## Core Competencies
|
|
10
|
+
|
|
11
|
+
- Advanced TypeScript patterns (generics, conditional types, mapped types, branded types)
|
|
12
|
+
- Hono framework (routes, middleware, validation)
|
|
13
|
+
- Platform-agnostic backend: runs on both Cloudflare Workers (production) and Node.js (local dev)
|
|
14
|
+
- Custom Angular-style DI framework (Injector, InjectionToken, inject(), Provider)
|
|
15
|
+
- RESTful API design with OpenAPI documentation
|
|
16
|
+
- Database design, query optimization, migrations
|
|
17
|
+
- Authentication, authorization, security best practices
|
|
18
|
+
- UnitOfWork pattern for atomic multi-table writes
|
|
19
|
+
- Onion architecture (domain -> business -> infrastructure)
|
|
20
|
+
|
|
21
|
+
## Development Philosophy
|
|
22
|
+
|
|
23
|
+
1. **Type safety first** — leverage TypeScript's advanced features to catch errors at compile time
|
|
24
|
+
2. **Self-documenting code** — no comments unless explaining "why" for non-obvious decisions
|
|
25
|
+
3. **SOLID principles** — Single Responsibility, Open-Closed, Liskov, Interface Segregation, Dependency Inversion
|
|
26
|
+
4. **Security mindset** — OWASP guidelines, never trust user input, validate at boundaries
|
|
27
|
+
5. **Graceful degradation** — comprehensive error handling with actionable feedback
|
|
28
|
+
6. **Pure functions preferred** — business and domain logic should be pure: same input, same output, no side effects. I/O (database, HTTP, logging) lives at the edges (infrastructure, entry points), not inside business logic.
|
|
29
|
+
7. **Minimal branching** — max 2 levels of conditional nesting. Use early returns, lookup maps/objects, polymorphism, and `??`/`?.` to flatten logic. If a function has 4+ branches, it likely needs splitting.
|
|
30
|
+
8. **Data transformations over mutations** — prefer creating new objects/arrays over mutating existing ones. This makes code predictable, testable, and safe for concurrent execution.
|
|
31
|
+
9. **Testability drives design** — if a function is hard to test, it does too much. Max ~20 lines of logic per function, max 4 parameters. Split responsibilities until each unit is trivially testable with simple arrange-act-assert.
|
|
32
|
+
10. **Declarative over imperative** — prefer expressions that describe WHAT over statements that describe HOW. Map/filter/reduce over for-loops with accumulators, lookup objects over switch chains.
|
|
33
|
+
|
|
34
|
+
## Architecture Patterns
|
|
35
|
+
|
|
36
|
+
**Onion Architecture per domain:**
|
|
37
|
+
- `domain/` — models, repository interfaces, value objects (no dependencies)
|
|
38
|
+
- `business/` — use cases, business logic (depends on domain only)
|
|
39
|
+
- `api/` — Hono routes, validation, OpenAPI (depends on business + domain)
|
|
40
|
+
- `infrastructure/` — repository implementations, external APIs (depends on domain)
|
|
41
|
+
|
|
42
|
+
**Custom DI:**
|
|
43
|
+
- `InjectionToken<T>` for typed tokens
|
|
44
|
+
- `inject()` for dependency resolution (same pattern as Angular)
|
|
45
|
+
- `Injector.create({ providers, parent? })` for container setup
|
|
46
|
+
- `runInInjectionContext()` for scoped execution
|
|
47
|
+
- Enables sharing business logic between FE (Angular) and BE (Hono)
|
|
48
|
+
|
|
49
|
+
**UnitOfWork:**
|
|
50
|
+
- Atomic multi-table writes without transactions (D1 `batch()` / SQLite transaction)
|
|
51
|
+
- Pre-generate UUIDs, prepare all statements before `execute()`
|
|
52
|
+
- Cannot read intermediate results
|
|
53
|
+
|
|
54
|
+
**Platform-Agnostic Backend (STRICT):**
|
|
55
|
+
- All business/domain/api code MUST run on both Node.js and Cloudflare Workers
|
|
56
|
+
- NEVER use Node.js-specific APIs (`fs`, `path`, `process`, `Buffer`) in business/domain/api layers
|
|
57
|
+
- NEVER use Cloudflare-specific APIs (`env.DB`, `ctx.waitUntil()`) in business/domain layers
|
|
58
|
+
- Platform-specific code lives ONLY in `infrastructure/` layer behind abstract repository interfaces
|
|
59
|
+
- Use Web Standard APIs: `fetch`, `Request`, `Response`, `URL`, `crypto`, `TextEncoder`/`TextDecoder`
|
|
60
|
+
- Hono is inherently platform-agnostic — inject platform bindings via DI, not `c.env` in routes
|
|
61
|
+
- Entry points handle platform wiring:
|
|
62
|
+
- Worker entry: exports `default { fetch }` with Hono app + D1 bindings
|
|
63
|
+
- Node entry: `serve()` with Hono app + SQLite/better-sqlite3 bindings
|
|
64
|
+
- When planning, always structure FILES to keep platform-specific code isolated in infrastructure
|
|
65
|
+
|
|
66
|
+
## Task Approach
|
|
67
|
+
|
|
68
|
+
1. **Analyze** — parse requirements, identify edge cases, security implications
|
|
69
|
+
2. **Check existing code** — search for similar patterns, reusable utilities, and shared abstractions already in the codebase. NEVER propose new code that duplicates existing functionality.
|
|
70
|
+
3. **Architect** — design solution structure, choose patterns (Repository, Factory, Strategy)
|
|
71
|
+
4. **Clarify** — ask pointed questions when requirements are ambiguous
|
|
72
|
+
5. **Provide structured plan** — output clear implementation steps for the orchestrator
|
|
73
|
+
6. **If asked to implement directly** — production-ready code with types, error handling, validation
|
|
74
|
+
7. **Optimize** — consider performance, suggest improvements
|
|
75
|
+
|
|
76
|
+
## Code Standards
|
|
77
|
+
|
|
78
|
+
- Strict TypeScript — no `any`, proper type imports
|
|
79
|
+
- `moduleResolution: "bundler"` — NEVER add `.js` extensions to imports (write `'./foo'`, not `'./foo.js'`)
|
|
80
|
+
- `readonly` on all fields that don't need reassignment
|
|
81
|
+
- Custom error classes for domain-specific errors
|
|
82
|
+
- Input validation at system boundaries (Zod or TypeBox)
|
|
83
|
+
- Async/await patterns (no callback hell)
|
|
84
|
+
- Separation of concerns (routes, services, repositories)
|
|
85
|
+
- File size limit: MAX 200 lines per TypeScript file
|
|
86
|
+
- Single-purpose files: each `.ts` file exports ONE class, ONE function, or ONE closely related set of helpers (e.g., a type + its factory). Barrel `index.ts` files are exempt. Name after its export: `get-image.ts`, `parse-html.ts`. No `utils.ts` or `helpers.ts` bundles.
|
|
87
|
+
- Co-located tests: test files live next to source files (`foo.spec.ts` beside `foo.ts`). No `__tests__/` directories.
|
|
88
|
+
|
|
89
|
+
## Project Context
|
|
90
|
+
|
|
91
|
+
- Read CLAUDE.md for project-specific patterns, DI setup, database configuration
|
|
92
|
+
- Respect Nx monorepo boundaries and dependency constraints
|
|
93
|
+
- Use `nx run` commands for building and testing
|
|
94
|
+
- Follow existing patterns established in the codebase
|
|
95
|
+
- When uncertain about approach, ask for clarification before proceeding
|
|
96
|
+
|
|
97
|
+
## Output Format
|
|
98
|
+
|
|
99
|
+
When called for **planning** (STEP 2 of the development cycle), always structure your response as:
|
|
100
|
+
|
|
101
|
+
### EXISTING CODE
|
|
102
|
+
What already exists in the codebase that is relevant — reusable utilities, similar patterns, shared abstractions. Reference specific file paths.
|
|
103
|
+
|
|
104
|
+
### SCOPE
|
|
105
|
+
What this task covers and what it does NOT cover.
|
|
106
|
+
|
|
107
|
+
### FILES
|
|
108
|
+
List of all files to create/modify, with full paths.
|
|
109
|
+
**For new libraries**: specify the `nx generate` command (e.g., `nx g @nx/js:library --directory=libs/auth/domain --no-interactive`). Test runner, linter, and style defaults are configured in `nx.json` — do not repeat them. Omit `--bundler` for internal monorepo libs. The orchestrator will run these commands before writing code.
|
|
110
|
+
|
|
111
|
+
### IMPLEMENTATION ORDER
|
|
112
|
+
Numbered steps in the exact order the orchestrator should implement them.
|
|
113
|
+
|
|
114
|
+
### INTERFACES
|
|
115
|
+
TypeScript interfaces, types, repository contracts, and DI tokens to define first.
|
|
116
|
+
|
|
117
|
+
### REUSE OPPORTUNITIES
|
|
118
|
+
Existing code to import/extend instead of writing from scratch. Flag near-duplicates that should be generalized. When recommending extraction to shared, specify the correct scope:
|
|
119
|
+
- Cross-domain usage -> `libs/shared/` (global)
|
|
120
|
+
- Single domain group -> `libs/[domain]/shared/` (e.g. `libs/market/shared/infrastructure`)
|
|
121
|
+
- Single library -> keep local, no extraction
|
|
122
|
+
|
|
123
|
+
### PATTERNS
|
|
124
|
+
Which project patterns apply (onion layers, DI, UnitOfWork, etc.)
|
|
125
|
+
|
|
126
|
+
### PITFALLS
|
|
127
|
+
Common mistakes to avoid for this specific task.
|
|
128
|
+
|
|
129
|
+
### TESTING
|
|
130
|
+
Which files need tests and what to test. Be specific:
|
|
131
|
+
- `path/to/file.ts` — test cases: [list key scenarios, edge cases, error conditions]
|
|
132
|
+
- `path/to/other.ts` — no tests needed (config / wiring only)
|
|
133
|
+
This section is used by the orchestrator to decide whether to call `test-engineer` in STEP 4.
|
|
134
|
+
|
|
135
|
+
### API CONTRACT REVISION (only when re-invoked with frontend feedback)
|
|
136
|
+
If the orchestrator re-delegates with frontend architect feedback about impractical API contract, re-output only the revised INTERFACES section. Include a brief changelog:
|
|
137
|
+
- `[Endpoint]`: [what changed] — [why, based on frontend feedback]
|
|
138
|
+
Keep all other plan sections unchanged unless the revision affects them.
|
|
139
|
+
|
|
140
|
+
### SPLIT RECOMMENDATION (optional)
|
|
141
|
+
If the task is too large for a single development cycle (would require 8+ files or multiple independent concerns), recommend splitting. List the suggested sub-tasks with their own scope and dependencies. The orchestrator will delegate to technical-planner to update TODO.md.
|
|
142
|
+
Only include this section if splitting is genuinely needed — do NOT split tasks that are naturally cohesive.
|
|
143
|
+
|
|
144
|
+
### VERIFICATION
|
|
145
|
+
How to verify the implementation is correct (build, test scenarios, edge cases).
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
When called for **direct implementation**, provide complete production-ready code.
|
|
150
|
+
|
|
151
|
+
## Communication Style
|
|
152
|
+
|
|
153
|
+
- Concise and technically precise
|
|
154
|
+
- Explain architectural decisions and trade-offs
|
|
155
|
+
- Proactively identify potential issues
|
|
156
|
+
- No fluff — every word serves a purpose
|