AI & Agents · Pro

Build Your Own AI Coding Agent

A terminal coding agent that reads your repo, plans edits, runs tools in a loop, and opens PRs with a real agent harness and permission gates

Pro20-35 hoursTypeScriptPythonAI

You will build a fully agentic CLI tool that accepts a plain-English task, explores a real Git repository using tree-sitter and ripgrep, plans a sequence of file edits, executes them through a Claude-powered tool-calling loop, and opens a pull request when done. The project teaches you exactly how production coding agents work under the hood: the plan-act-observe loop, JSON-schema tool definitions, permission gating, and safe sandboxing. Unlike toy wrappers around a single LLM call, this agent reasons across multiple steps, recovers from failures, and requires you to design the permission model yourself. Building it gives you the mental model to extend, audit, or replace any agentic coding product on the market.

What you build

  • Accepts a task description from the CLI and autonomously explores the repository using Glob, Grep, and tree-sitter AST queries to locate relevant files
  • Runs a multi-step tool-calling loop: plan, read, edit, verify, repeat until the task is complete or an abort condition is hit
  • Permission gate prompts the user before any destructive write or shell command, with allow-once and allow-always options
  • Validates every proposed edit against the original AST to catch syntactically broken patches before they are written to disk
  • Executes test commands after edits and feeds stdout/stderr back into the next loop iteration so the agent can self-correct
  • Shells out to git to stage changes, write a commit message, push the branch, and open a pull request via the GitHub CLI
  • Streams agent reasoning and tool calls to the terminal in real time so you can follow every decision

What it teaches

  • Tool-calling loop mechanics: how a model iterates plan, tool-use, observe, and revise until convergence
  • JSON-Schema tool definition design: writing schemas tight enough to prevent invalid inputs without being so strict the model refuses to call the tool
  • Permission gating and sandboxing: how to classify agent actions by risk level and prompt for human approval only when warranted
  • AST-based validation: using tree-sitter to cheaply verify syntactic correctness after every edit without running a full compiler
  • Agent self-correction: feeding tool errors back into the context so the model can diagnose and retry rather than silently fail
  • Git workflow automation: programmatically staging, committing, and opening PRs as the final artifact of an autonomous agent run

How it works

  1. 1

    User Prompt

    • task string
    • target repo path

    dispatch

  2. 2

    Repo Exploration

    • Glob file scan
    • ripgrep search
    • tree-sitter AST

    plan

  3. 3

    Agent Loop

    • tool-call stream
    • permission gate
    • result inject

    verify

  4. 4

    Edit + Validate

    • edit_file write
    • AST error check
    • test runner

    finalize

  5. 5

    Git + PR

    • stage changes
    • commit message
    • gh pr create
fig. 01 — how the coding agent processes a task from plain-english input to a merged pull request

Sign in to open the build guide

Free account. Get the step-by-step build and every resource link.

Sign in to continue

Take it further

  • Add a subagent architecture where a planner agent decomposes the task and spawns one worker agent per file cluster, then merges their edits and resolves conflicts before committing.
  • Integrate an MCP server that exposes your company's internal API documentation as a resource, letting the agent look up type signatures and deprecation notices before proposing edits.
  • Replace the GitHub CLI PR step with a full code-review subagent that reads the diff, scores it against a rubric, and posts inline review comments via the GitHub REST API before marking the PR ready for human review.

More like this

All projects