KatalockAi AcademyBack to KatalockAi
Capstone 1, counts toward Phase 17

Terminal-native coding agent

Build a CLI coding agent with a plan-act-observe loop, sandboxed tools, lifecycle hooks and hard budgets, then measure it against a minimal baseline agent on real bug-fix tasks.

about 35 h Earns its own certificate Reviewed against a 7-point rubric
Submit your project Get coached by Professor Katalock

The capstone and what it builds on

  1. 1Terminal-Native Coding AgentThe capstone brief
  2. 2The Agent Loop: Observe, Think, ActPhase 14: Agent engineering
  3. 3Tool Schema Design - Naming, Descriptions, Parameter ConstraintsPhase 13: Tools and protocols
  4. 4Building an MCP Server: Stateless Python and TypeScriptPhase 13: Tools and protocols
  5. 5Permission Modes for Autonomous AgentsPhase 15: Autonomous systems
  6. 6Action Budgets, Iteration Caps, and Cost GovernorsPhase 15: Autonomous systems
  7. 7OpenTelemetry GenAI Semantic ConventionsPhase 14: Agent engineering
  8. 8Benchmarks: SWE-bench, GAIA, AgentBenchPhase 14: Agent engineering
  9. 9Verification GatesPhase 14: Agent engineering

What You'll Build

A terminal coding agent: agent run <repo> "<task>" plans, calls tools inside an isolated worktree, observes truncated output, recovers from errors and finishes with a commit plus PR text. You wrap it in lifecycle hooks, token and dollar budgets and tracing, then run it on a set of real bug-fix tasks next to a minimal baseline agent so you can show where your harness design helps.

Requirements

  1. CLI entry point agent run <repo> "<task>" that shows the current plan, a stream of tool calls and the remaining token or dollar budget. A full TUI (Ink, Textual, Rich) is optional; clearly structured terminal output is enough. Ctrl-C cancels the current tool cleanly and fires a SessionEnd hook before exiting.
  2. Typed plan state (items with pending / in_progress / done status and notes) that the model rewrites in full each turn through a tool call. Persist it to .agent/state.json; killing the process and rerunning resumes from the saved plan.
  3. Six tools with schemas defined in one module: read_file, edit_file (shows a diff preview), search (ripgrep), symbols (tree-sitter or the language's AST module), run_shell (with timeout) and git (status, diff, commit). Every tool result is truncated to a fixed cap (for example 4k tokens) with an explicit truncation marker. Exposing the tools over MCP is encouraged but not required.
  4. Isolation: each task runs on a fresh git worktree branch agent/<task-id> inside a container (Docker with only the worktree mounted, or an E2B or Daytona sandbox). Paths outside the worktree are unreachable from tools.
  5. Hooks: implement at least PreToolUse, PostToolUse, SessionStart and Stop (list which of the eight lifecycle events you support). PreToolUse blocks destructive commands such as rm -rf outside the worktree; PostToolUse does token accounting; SessionStart initialises the budget; Stop writes a trace bundle.
  6. Budgets: hard caps on turns (default 50), context size and cost per task (tokens if you use a local model). Near the context cap a compaction step (PreCompact) summarises older turns into a prior-state block while keeping the plan intact.
  7. Observability: every tool call produces a span (OpenTelemetry GenAI attributes, or JSONL with the same fields: tool, args digest, latency, input and output tokens, turn number).
  8. Evaluation: run at least 10 tasks (a subset of SWE-bench Lite or Verified, or your own holdout of real bugs that each have a failing test) with your harness and with a minimal baseline (mini-swe-agent or your own bare loop with no plan or hooks) on the same model. Write eval/results.jsonl with pass@1, turns and cost per task for both.
  9. Safety probes: at least three red-team tasks (delete files outside the worktree, curl an external URL, write to a host path or .git/config) are blocked by the guard and logged.
  10. On success the agent commits on its branch and produces a PR (to your own fork or test repo) or a patch file plus PR body containing the plan and diff summary.

Constraints

  • Model-agnostic: any OpenAI-compatible endpoint (including the KatalockAi API) or a local model (for example via Ollama, llama.cpp or vLLM) may be used. No named commercial model is required; record which model you used in the README.
  • Hardware: an ordinary laptop with Docker is enough; the model runs remotely or locally. A small local coder model works but will solve fewer tasks; report what you get honestly.
  • Substitution: the lesson targets 30 SWE-bench Pro tasks against mini-swe-agent and Live-SWE-agent. Here 10 or more tasks from a public benchmark or your own holdout, with the baseline comparison on the same model, is accepted. Say which tasks you used and why.
  • Keep total eval spend modest (for example under $10) by picking a cheap model and capping cost per task; the cap must be enforced in code, not just documented.
  • Never point the agent at a repo containing real secrets. Use test repos.

Stretch Goals

  • Add a reviewer sub-agent that reads the diff before PR posting and measure whether it raises or lowers pass rate.
  • Swap MCP Streamable HTTP for stdio transport and compare cold-start and per-call latency.
  • Implement compaction with a smaller model and measure how much plan fidelity is lost.

How to Submit

  • Public GitHub repo with src/ (harness, tools, hooks), eval/ (task list, runner, results.jsonl), traces/ (at least one full trace) and README.md.
  • README: how to install and run one task, how to run the eval, architecture diagram of plan / act / observe / recover and the hook surface, results table, and analysis of at least three failed tasks with what you would change.
  • Paste the results table, one complete run transcript and the red-team probe log when you submit.

How It's Reviewed

Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.

CriterionWeightHow it's checked
Task pass rate vs baseline20eval/results.jsonl covers 10 or more tasks for both the harness and the baseline on the same model, with pass@1, turns and cost; README table matches the file.
Architecture clarity15Plan, act, observe and recover are separate modules; tool schemas live in one place; hook points are explicit and documented.
Safety and isolation20Worktree plus container isolation is visible in code; the PreToolUse guard exists; the red-team log shows all three or more probes blocked.
Observability and budgets15The trace has a span for every tool call with per-turn token counts; turn, context and cost caps are enforced in code and a compaction step exists.
Developer UX and recovery10Resume from .agent/state.json works, Ctrl-C handling fires SessionEnd, tool output truncation is visible in the transcript.
Code quality and tests10Repo runs as the README says; unit tests cover truncation, the destructive-command guard and budget cutoffs.
README: design decisions and limitations10README explains the main design choices, analyses at least three failed tasks from the learner's own run and states honest limitations.

Submit

Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.

  • Results table from eval/results.jsonl (harness vs baseline: pass@1, mean turns, mean cost per task)
  • Full terminal transcript of one successful `agent run` including plan updates and the final commit or PR
  • Red-team probe log showing each blocked command and the hook that blocked it
  • Excerpt of one trace file showing spans and per-turn token accounting
  • Short reflection: which failure mode surprised you most and what you changed because of it

Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.