top | item 47087313

Show HN: A Self-Paced Exercise to Build a CLI Coding Agent from Scratch

2 points| primaprashant | 11 days ago |github.com

I ran a hands-on workshop in Tokyo where ~50 engineers built a CLI coding agent from scratch in Python. I've converted it into a self-paced exercise.

GitHub Repo: https://github.com/primaprashant/alduin

We start from a skeleton repo with a basic input loop and no LLM. Over seven phases, we add the Anthropic API, implement tools (read file, edit file, bash), and build the core agent loop.

Each phase has hints and a reference commit if you get stuck.

1 comment

order

primaprashant|11 days ago

I ran this live in Tokyo with ~50 engineers. The biggest "aha" moment was Phase 4, when the agent loop closes and the LLM starts chaining tool calls autonomously. People go from "I'm building a chatbot" to "oh, this is an agent".

Also, there have been plenty of "build a coding agent in 200 lines" posts on HN in the past year, and they're great for seeing the final picture. I created this simple structured exercise so we start from an empty loop and build each piece ourself, phase by phase. So instead of just reading the implementation, I hope more people try the implementation themselves.

These are the 7 phases of implementation:

  1. LLM in the loop: replace the canned response with an actual LLM call
  2. Read file tool: implement the tool + pass its schema to the LLM + detect tool use in the response
  3. Tool execution: execute the tool the LLM requested and display the result
  4. Agent loop: the inner loop where tool results go back to the LLM until no more tool calls
  5. Edit file tool: create and edit files
  6. Bash tool: execute shell commands with user confirmation
  7. Memory: use the agent to build the agent, add AGENTS.md support for persistent memory across sessions

Feedback and PRs welcome. Happy to answer any questions.