147 lines
4.0 KiB
Markdown
147 lines
4.0 KiB
Markdown
---
|
|
name: init
|
|
description: "Setup task: scaffold .loop/ directory and generate config for the agent loop harness. Not a creative task — do not brainstorm or generate ideas. Reads existing specs if present."
|
|
---
|
|
|
|
# /init — Initialize Agent Loop for a Project
|
|
|
|
Set up the agent loop harness in the current project. This is infrastructure setup, not creative work.
|
|
|
|
**IMPORTANT:** Do NOT invoke brainstorming, planning, or idea-generation skills. This skill handles its own flow.
|
|
|
|
## Instructions
|
|
|
|
Follow these steps exactly. Do not skip or reorder them.
|
|
|
|
### Step 1: Scaffold .loop/ Directory
|
|
|
|
Check if `.loop/` already exists in the project root.
|
|
|
|
**If `.loop/` already exists** and contains `prd.json`, ask the user if they want to re-initialize. If yes, delete `.loop/` and continue. If no, skip to Step 3.
|
|
|
|
**Create `.loop/` and copy ALL required harness files.** Run these commands exactly:
|
|
|
|
```bash
|
|
mkdir -p .loop
|
|
```
|
|
|
|
Then check if the plugin root has the harness files. Try these paths in order:
|
|
1. `${CLAUDE_PLUGIN_ROOT}/prompts/` (if CLAUDE_PLUGIN_ROOT env var is set)
|
|
2. `~/.claude/plugins/cache/agent-loop/agent-loop/*/prompts/` (glob for any version)
|
|
|
|
Copy ALL of these directories and files — every one is required:
|
|
|
|
```bash
|
|
# Find the harness source (plugin cache)
|
|
HARNESS_SRC=$(ls -d ~/.claude/plugins/cache/agent-loop/agent-loop/*/prompts/.. 2>/dev/null | head -1)
|
|
|
|
if [ -n "$HARNESS_SRC" ]; then
|
|
cp -r "$HARNESS_SRC/prompts" .loop/
|
|
cp -r "$HARNESS_SRC/templates" .loop/
|
|
cp -r "$HARNESS_SRC/lib" .loop/
|
|
cp "$HARNESS_SRC/loop.sh" .loop/
|
|
chmod +x .loop/loop.sh
|
|
fi
|
|
```
|
|
|
|
**Verify the copy worked.** Check that these paths exist:
|
|
- `.loop/prompts/generator/_base.md`
|
|
- `.loop/prompts/evaluator/_base.md`
|
|
- `.loop/templates/progress.md.template`
|
|
- `.loop/lib/state.sh`
|
|
- `.loop/loop.sh`
|
|
|
|
If any are missing, tell the user the scaffold failed and show which files are missing.
|
|
|
|
Create `.loop/.gitignore`:
|
|
|
|
```
|
|
prd.json
|
|
progress.md
|
|
progress-archive.md
|
|
config.json
|
|
init.sh
|
|
contracts/
|
|
triage/
|
|
archive/
|
|
.archive-staging/
|
|
.last-branch
|
|
.loop.lock
|
|
```
|
|
|
|
### Step 2: Check for Existing Specs
|
|
|
|
Search for existing design documents or specs:
|
|
- `docs/superpowers/specs/*.md`
|
|
- `docs/specs/*.md`
|
|
- `SPEC.md`, `PRD.md`, `DESIGN.md` at root
|
|
|
|
**If a spec is found:**
|
|
> "I found an existing spec at `{path}`. I'll use this as the basis for generating stories."
|
|
|
|
Read it. The user does NOT need to re-describe what they want. Set mode to `implement` and skip to Step 4.
|
|
|
|
**If no spec is found**, proceed to Step 3.
|
|
|
|
### Step 3: Mode Selection
|
|
|
|
Ask the user:
|
|
|
|
> **What would you like to do?**
|
|
>
|
|
> a) **Explore** — Read-only codebase analysis. No code changes.
|
|
> b) **Implement** — Build a feature. Code changes, commits, and tests.
|
|
> c) **Fix** — Targeted bug fixes or tech debt.
|
|
|
|
For **implement** without a spec: "Describe the feature in 1-3 sentences."
|
|
For **explore**: "What areas should I focus on?"
|
|
For **fix**: "Do you have a list of issues, or should I find them?"
|
|
|
|
Also read the project to detect the tech stack:
|
|
- Check for `package.json`, `Cargo.toml`, `pyproject.toml`, `go.mod`, etc.
|
|
- Run `ls` on the project root
|
|
|
|
### Step 4: Generate Configuration
|
|
|
|
Create `.loop/config.json` with this EXACT structure:
|
|
|
|
```json
|
|
{
|
|
"tool": "claude",
|
|
"mode": "<implement|explore|fix>",
|
|
"maxIterations": 20,
|
|
"skipEval": false,
|
|
"evalRetries": 2,
|
|
"autoHooks": true,
|
|
"branchPrefix": "loop/",
|
|
"scopeBudgets": {
|
|
"explore": {
|
|
"maxFilesToRead": 15,
|
|
"maxLinesToWrite": 0,
|
|
"maxFilesToModify": 0
|
|
},
|
|
"implement": {
|
|
"maxFilesToRead": 50,
|
|
"maxLinesToWrite": 500,
|
|
"maxFilesToModify": 10
|
|
},
|
|
"fix": {
|
|
"maxFilesToRead": 30,
|
|
"maxLinesToWrite": 200,
|
|
"maxFilesToModify": 5
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
Adjust `maxIterations` based on estimated story count (stories + 30% for rejections).
|
|
|
|
Create `.loop/init.sh` with project-specific setup commands. Make it executable.
|
|
|
|
### Step 5: Flow into Planning
|
|
|
|
Say:
|
|
> "Project configured. Generating stories..."
|
|
|
|
Then invoke `/agent-loop:plan`. If a spec was found in Step 2, tell the plan skill to use it.
|