Autonomous development pipeline using a Python CLI and claude_code_sdk with strict stage contracts.
curl -fsSL https://raw.githubusercontent.com/0xjgv/kern/main/install.sh | sh- Claude CLI
python3git
Installer behavior:
- Creates managed virtualenv at
~/.local/share/kern/.venv - Symlinks
kernto~/.local/bin/kern
kern --updateStage 0 Populate Queue
-> Stage 1 Research
-> Stage 2 Design
-> Stage 3 Structure
-> Stage 4 Plan
-> Stage 5 Implement
-> Runtime Validation + Evaluation (soft gate)
- fail critical checks -> one fix retry (Stage 5) -> re-validate/re-score
-> Stage 6 Review & Commit
kern --help
kern
kern -c 10
kern 7
kern --hint "focus on validation edge cases"
kern -v
kern -nAll runtime state is written under the current working directory .kern/:
.kern/handoff/task-<id>.mdappend-only stage handoff + validation/evaluation notes.kern/state/task-<id>.jsonnormalized task state (planned files, success criteria).kern/reports/task-<id>.jsonlper-attempt evaluation reports.kern/runs/<run_id>/events.jsonlper-stage execution events (duration, usage, cost, status)
Stages 1..6 must emit machine-parseable output:
<<MACHINE>>block containing one JSON object<<HANDOFF>>block for stages1..5(stage 6 optional)- Exact final success line:
- Stage 1:
SUCCESS task_id=<ID>orSUCCESS task_id=noneand optionalskip=true - Stages 2-5:
SUCCESS task_id=<ID> - Stage 6:
SUCCESS
- Stage 1:
Malformed stage output fails fast.
After Stage 5, runtime validates success criteria using:
file_existsfile_containsfile_not_containscommand_succeedsgit_diff_includes
Criteria are read from normalized Stage 4 machine output stored in .kern/state/task-<id>.json.
Handoff parsing is retained as compatibility fallback.
Soft gate policy:
- Critical failures (
file_exists,file_contains,file_not_contains,command_succeeds) trigger one automatic fix retry. - If critical failures remain after retry, task fails and Stage 6 is skipped.
- Advisory failures (scope drift,
git_diff_includes, score regression) are recorded but do not block commit.
Policy is enforced through SDK options (allowed_tools, permission_mode, model):
| Stage | Mode | Tool Policy |
|---|---|---|
| 0: Populate | Read-only | Read, Glob, Grep, LS, TaskGet, TaskList, TaskCreate, TaskUpdate |
| 1: Research | Read-only | Read, Glob, Grep, LS, TaskGet, TaskList, TaskUpdate, Task |
| 2: Design | Read-only | Read, Glob, Grep, LS, TaskGet, TaskList, TaskUpdate, Task |
| 3: Structure | Read-only | Read, Glob, Grep, LS, TaskGet, TaskList, TaskUpdate, Task |
| 4: Plan | Read-only | Read, Glob, Grep, LS, TaskGet, TaskList, TaskUpdate, Task |
| 5: Implement | Full access | permission_mode=bypassPermissions |
| 6: Commit | Commit-only | Read, Glob, Grep, LS, TaskGet, TaskList, TaskUpdate, Bash |
Each prompt receives placeholders rendered by runtime:
| Context | Stage 0 | Stage 1 | Stage 2 | Stage 3 | Stage 4 | Stage 5 | Stage 6 |
|---|---|---|---|---|---|---|---|
| SPEC_FILE | ✓ | - | - | - | - | - | - |
| TASK_ID | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| HINT | - | ✓ | - | - | - | ✓ | - |
| RECENT_COMMITS | - | ✓ | - | - | - | - | ✓ |
| DIFF | - | - | - | - | - | - | ✓ |
| HANDOFF_FILE | - | - | ✓ | ✓ | ✓ | ✓ | ✓ |
kern supports either:
- Logged-in Claude CLI session (
claude auth), or ANTHROPIC_API_KEYenvironment variable
ANTHROPIC_API_KEY is not required if a valid CLI login session exists.
from kern.runtime import run
exit_code = run(
task_id=None,
max_tasks=5,
hint="",
dry_run=False,
verbose=False,
)./scripts/release.sh 0.1.5Release workflow:
- Validates version and tag.
- Injects version into
src/kern/version.pyandpyproject.toml. - Packages Python source + prompts + install assets.
- Publishes
kern.tar.gzwith checksum.