## Coding Challenge #112 - AI Coding Agent
This challenge is to build your own AI coding agent - a command-line tool that can read, understand, and modify code on your behalf by combining a large language model with practical software engineering tools.
AI coding agents have rapidly become part of the modern developer's toolkit. Tools like Claude Code, Codex, Cursor, Kiro, and AmpCode let you describe what you want in natural language and the agent figures out which files to read, what changes to make, and how to verify its work. Under the hood, they're surprisingly approachable: a loop that talks to an LLM, a set of tools the model can call, and some orchestration to keep everything on track.
By building your own, you'll gain a deep understanding of how these tools actually work - the agentic loop, tool use, context management, and all the engineering that turns a chat API into a coding assistant. You'll also end up with something you can actually use on your own projects.
The Challenge - Building Your Own AI Coding Agent
You're going to build a command-line AI coding agent, a simplified version of tools like Claude Code, Codex and AmpCode. It starts as a simple chat interface, and step by step you'll add the ability to read files, edit code, run shell commands, search a codebase and manage context. By the end, you'll have a working agent that can navigate a real project and make meaningful changes to it.
To really get the most from this challenge I suggest you call the LLM provider’s REST API directly and manage all the data yourself, this will give you the best understanding of AI agents and how they work.
Step Zero
In this introductory step you're going to set your environment up ready to begin developing and testing your solution.
You'll need to make a few decisions:
- Choose your LLM provider. You need a model that supports tool calling (also called function calling). Most major providers support this: Anthropic, OpenAI, Google (Gemini), Mistral, or local models via Ollama. Check your chosen provider's documentation for their tool-calling API - you'll be using it heavily throughout this challenge.
- Choose your programming language. Pick something you're comfortable building CLI tools in. You'll be doing a fair amount of file I/O, process spawning, and JSON handling. Python, TypeScript, Go, and Rust all work well. The language doesn't matter nearly as much as your comfort with it.
- Get your API key set up. Make sure you can make a basic chat completion request to your chosen provider and get a response back before moving on.
Prepare a small test project to use as a playground throughout the challenge - a simple application with a few files in a couple of directories. You'll be pointing your agent at this project to test reading, editing, and searching.
Testing: Make a simple API call to your LLM provider with a basic prompt like "Hello, who are you?" and verify you get a coherent response. If you're using a local model, confirm it's running and accessible. I suggest using curl to do this so you know how to call the REST API for your provider.
Recommended by LinkedIn
Step 1
In this step your goal is to build the core agentic loop with streaming responses.
The heart of any coding agent is the loop: read user input, send it to the LLM, display the response, repeat. Build a REPL (read-eval-print loop) that takes input from the terminal, sends it to your LLM as a chat message, and streams the response back to the terminal as it arrives.
Streaming matters here. LLM responses can take several seconds to generate in full, and watching text appear token by token is a much better experience than staring at a blank screen. Your provider's API will have a streaming option - use it.
Your loop should maintain a conversation history so the model has context from earlier in the session. Each time you send a request, include the full conversation so far: all previous user messages and assistant responses.
Handle the basics gracefully: let the user exit the session cleanly, and don't crash if the API returns an error.
Testing:
- Start your agent and have a multi-turn conversation. Ask a question, then ask a follow-up that references the previous answer. The model should understand the context.
- Verify responses stream to the terminal incrementally rather than appearing all at once.
- Check that you can exit the session cleanly (e.g. with Ctrl+C or typing “quit” or "exit").
- Disconnect from the network and send a message - verify the agent handles the error without crashing.
Continued...
You can find the rest of this Coding Challenge on the Coding Challenges Substack.
Challenges like this work because they mirror reality. When people connect concepts to actual applications, understanding becomes far more durable and practical.
Never skip practice! Even the well-known concepts need to be practiced frequently in order to stay fresh in your mind.
The AI Coding Agent challenge is well-timed, given how fast that space is moving. Building one from scratch forces you to understand tool orchestration and context management in ways that using Copilot never will. Of the 23 challenges listed, which one has produced the most surprising skill transfer to real job tasks? John Crickett
Building forces you to confront the tradeoffs and edge cases that tutorials skip. These challenges are a solid way to turn concepts into real understanding.
Building your own AI coding agent is an excellent challenge and a great way to learn something new.