Skip to content

Commit 8b98806

Browse files
committed
docs: add MkDocs Material documentation site with GitHub Pages deploy
48 documentation pages covering getting started, workflow phases, all 16 commands, 10 agents, reference guides, and advanced features. GitHub Action deploys to Pages on push to main.
1 parent 467c2b8 commit 8b98806

51 files changed

Lines changed: 4288 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'docs/**'
8+
- 'mkdocs.yml'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: pages
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.12'
29+
30+
- run: pip install mkdocs-material
31+
32+
- run: mkdocs build --strict
33+
34+
- uses: actions/upload-pages-artifact@v3
35+
with:
36+
path: site
37+
38+
deploy:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
environment:
42+
name: github-pages
43+
url: ${{ steps.deployment.outputs.page_url }}
44+
steps:
45+
- id: deployment
46+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.claude/*.local.md
66
.claude/*.local.json
77
.claude/specs/.worktrees/
8+
site/

docs/advanced/ci-cd.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# CI/CD integration
2+
3+
The post-implementation scripts are designed to work in CI pipelines. They use exit codes and promise markers to communicate status to the calling process.
4+
5+
## Exit codes
6+
7+
| Script | Exit 0 | Exit 1 |
8+
|--------|--------|--------|
9+
| `spec-verify.sh` | All smoke tests pass (PASS) | One or more checks failed (FAIL) |
10+
| `spec-loop.sh` | Completed normally (all tasks done or max iterations reached) | Unexpected error |
11+
| `spec-accept.sh` | Script completed (check promise marker for ACCEPTED/REJECTED) | Script error |
12+
13+
## Promise markers
14+
15+
Scripts that produce structured outcomes write promise markers in their output:
16+
17+
| Script | Markers |
18+
|--------|---------|
19+
| `spec-loop.sh` | `<promise>COMPLETE</promise>` |
20+
| `spec-accept.sh` | `<promise>ACCEPTED</promise>` or `<promise>REJECTED</promise>` |
21+
| `spec-retro.sh` | `<promise>RETRO_COMPLETE</promise>` |
22+
23+
These markers let the calling script detect outcomes reliably without parsing human-readable prose.
24+
25+
## Example CI stages
26+
27+
### Post-deployment smoke test
28+
29+
Use `spec-verify.sh` as a deployment gate. The script exits 1 if any smoke test fails, which fails the CI step:
30+
31+
```bash
32+
spec-verify.sh --spec-name user-authentication \
33+
--url "$STAGING_URL" \
34+
--scope quick || exit 1
35+
```
36+
37+
For a full smoke test on staging before promoting to production:
38+
39+
```bash
40+
spec-verify.sh --spec-name user-authentication \
41+
--url "$STAGING_URL"
42+
```
43+
44+
### Acceptance gate before release
45+
46+
Check the promise marker from `spec-accept.sh` to gate the release stage:
47+
48+
```bash
49+
output=$(spec-accept.sh --spec-name user-authentication)
50+
if echo "$output" | grep -q '<promise>ACCEPTED</promise>'; then
51+
echo "Acceptance passed, proceeding to release"
52+
else
53+
echo "Acceptance failed, aborting release"
54+
exit 1
55+
fi
56+
```
57+
58+
### Automated implementation loop in CI
59+
60+
Run the implementation loop in CI with a bounded iteration count. The loop exits 0 when complete or when max iterations is reached:
61+
62+
```bash
63+
spec-loop.sh \
64+
--spec-name user-authentication \
65+
--max-iterations 30 \
66+
--no-worktree
67+
```
68+
69+
!!!warning
70+
Running `spec-loop.sh` in CI requires `claude --dangerously-skip-permissions`, which the script uses internally. Only do this in isolated CI environments where you control what code Claude can access and execute.
71+
72+
## Suggested pipeline order
73+
74+
For a full automated pipeline after implementation:
75+
76+
```bash
77+
# 1. Run acceptance testing
78+
spec-accept.sh --spec-name "$SPEC"
79+
80+
# 2. Deploy to staging (your deploy step here)
81+
82+
# 3. Smoke test on staging
83+
spec-verify.sh --spec-name "$SPEC" --url "$STAGING_URL" || exit 1
84+
85+
# 4. Generate release artifacts
86+
spec-release.sh --spec-name "$SPEC" --version-bump minor --release
87+
88+
# 5. Deploy to production (your deploy step here)
89+
90+
# 6. Verify production
91+
spec-verify.sh --spec-name "$SPEC" --url "$PROD_URL" --scope quick || exit 1
92+
```
93+
94+
## Scope flag for spec-verify.sh
95+
96+
`--scope quick` runs a lightweight health check — useful for production verification where you want fast feedback without running the full test suite. The default (no `--scope` flag) runs the full smoke test battery.

docs/advanced/crash-recovery.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Crash recovery
2+
3+
`spec-loop.sh` and `spec-team.sh` implement crash recovery via checkpoint commits. If Claude exits with a non-zero exit code during an iteration, the branch is automatically rolled back to the state before that iteration started.
4+
5+
## How checkpoints work
6+
7+
At the start of each iteration, before Claude is invoked, the script calls `create_checkpoint()` from `scripts/lib/checkpoint.sh`:
8+
9+
1. Check for uncommitted changes (staged or unstaged) in the working directory
10+
2. If changes exist, stage everything and create a commit: `checkpoint: pre-iteration N`
11+
3. Record the commit hash as `CHECKPOINT_SHA`
12+
13+
If there are no uncommitted changes (the previous iteration committed cleanly), no checkpoint commit is created and `CHECKPOINT_SHA` is empty.
14+
15+
## Rollback behavior
16+
17+
After Claude exits, the script checks the exit code:
18+
19+
- **Exit code 0** — success, no rollback needed
20+
- **Non-zero exit code with a checkpoint** — call `git reset --hard <CHECKPOINT_SHA>` to discard the failed iteration's partial work and return to the pre-iteration state
21+
- **Non-zero exit code without a checkpoint** — nothing to roll back, continue
22+
23+
If `git reset --hard` itself fails (rare), the script prints a critical warning and the path to the worktree so you can inspect manually.
24+
25+
## What triggers a non-zero exit
26+
27+
Claude exits non-zero when it encounters an unrecoverable error: tool failures, network issues, hitting context limits, or explicit errors. Rollback ensures these situations leave the codebase in a clean state rather than with half-written code.
28+
29+
## Checkpoint commits in git history
30+
31+
Checkpoint commits appear in git history with the message `checkpoint: pre-iteration N`. They are real commits on the spec branch. When you open a PR, you may want to squash or rebase these out:
32+
33+
```bash
34+
git rebase -i main
35+
```
36+
37+
## Manual recovery
38+
39+
If you need to recover manually, checkpoint commits are labeled and easy to find:
40+
41+
```bash
42+
git log --oneline | grep checkpoint
43+
```
44+
45+
Roll back to a specific checkpoint:
46+
47+
```bash
48+
git reset --hard <checkpoint-sha>
49+
```

docs/advanced/cross-spec-deps.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Cross-spec dependencies
2+
3+
Specs can declare dependencies on other specs. Execution scripts check that all declared dependencies are fully complete before starting any implementation work.
4+
5+
## Declaring dependencies
6+
7+
Add a `## Depends On` section to the spec's `requirements.md`:
8+
9+
```markdown
10+
## Depends On
11+
12+
- auth-system
13+
- database-migrations
14+
```
15+
16+
List one dependency per line as a bullet. Each entry is the name of another spec in `.claude/specs/`.
17+
18+
Remove the section entirely if the spec has no dependencies.
19+
20+
## What "complete" means
21+
22+
A dependency is considered complete when every task in its `tasks.md` satisfies all three conditions:
23+
24+
- `Status: completed`
25+
- `Wired: yes` or `Wired: n/a`
26+
- `Verified: yes`
27+
28+
A dependency with any task that does not meet all three conditions is considered incomplete, and the dependent spec's execution scripts will refuse to start.
29+
30+
## Dependency check behavior
31+
32+
When you run `spec-loop.sh`, `spec-exec.sh`, or `spec-team.sh`, the script calls `check_dependencies()` before creating any worktree or running any iteration.
33+
34+
If a dependency is not found:
35+
36+
```
37+
Error: Dependency spec not found: auth-system
38+
```
39+
40+
If a dependency has no `tasks.md`:
41+
42+
```
43+
Error: Dependency auth-system has no tasks.md
44+
```
45+
46+
If a dependency is incomplete:
47+
48+
```
49+
Error: Dependency incomplete: auth-system (4/7 tasks verified)
50+
```
51+
52+
The script exits with code 1. Fix or complete the dependency before running the dependent spec.
53+
54+
## Circular dependency detection
55+
56+
The scripts detect circular dependencies using a depth-first search before checking completion status. If a cycle is found, the script exits immediately with an error:
57+
58+
```
59+
Error: Circular dependency detected: spec-a -> spec-b -> spec-a
60+
```
61+
62+
Circular dependencies cannot be resolved automatically — you need to restructure your specs to break the cycle.
63+
64+
## Viewing dependency status
65+
66+
Use `/spec-status` to see the dependency status for the current spec:
67+
68+
```
69+
Dependencies:
70+
auth-system: complete (7/7 tasks verified)
71+
database-migrations: incomplete (3/5 tasks verified)
72+
```
73+
74+
This output comes from `get_dependency_status()` in `scripts/lib/deps.sh`, which reads the `## Depends On` section and checks each referenced spec.
75+
76+
## Multiple specs in parallel
77+
78+
Specs without dependencies on each other can run in parallel on separate worktrees. Because each spec gets its own branch (`spec/<name>`), parallel execution does not cause conflicts.
79+
80+
Specs with a dependency chain must run in order: complete the dependency first, then start the dependent spec.

0 commit comments

Comments
 (0)