[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-73210":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":31,"readmeContent":32,"aiSummary":33,"trendingCount":16,"starSnapshotCount":16,"syncStatus":15,"lastSyncTime":34,"discoverSource":35},73210,"how-to-build-a-coding-agent","ghuntley\u002Fhow-to-build-a-coding-agent","ghuntley","A workshop that teaches you how to build your own coding agent. Similar to Roo code, Cline, Amp, Cursor, Windsurf or OpenCode.","https:\u002F\u002Fghuntley.com\u002Fagent\u002F",null,"Go",5659,638,33,2,0,17,30,105,51,39.42,false,"trunk",true,[26,27,28,29,30],"agent","ai","cursor","tutorial","workshop","2026-06-12 02:03:10","# 🧠 Build Your Own Coding Agent via a Step-by-Step Workshop\n\nWelcome! 👋 This workshop will guide you through building your own **AI-powered coding assistant** — starting from a basic chatbot, and adding powerful tools like file reading, shell command execution, and code searching.\n\nYou don’t need to be an AI expert. Just follow along and build step-by-step!\n\n🌐 **Want a detailed overview?** Check out the blog post: [ghuntley.com\u002Fagent](https:\u002F\u002Fghuntley.com\u002Fagent\u002F)\n\n---\n\n## 🎯 What You'll Learn\n\nBy the end of this workshop, you’ll understand how to:\n\n- ✅ Connect to the Anthropic Claude API\n- ✅ Build a simple AI chatbot\n- ✅ Add tools like reading files, editing code, and running commands\n- ✅ Handle tool requests and errors\n- ✅ Build an agent that gets smarter with each step\n\n---\n\n## 🛠️ What We're Building\n\nYou’ll build 6 versions of a coding assistant. \n\nEach version adds more features:\n\n1. **Basic Chat** — talk to Claude\n2. **File Reader** — read code files\n3. **File Explorer** — list files in folders\n4. **Command Runner** — run shell commands\n5. **File Editor** — modify files\n6. **Code Search** — search your codebase with patterns\n\n```mermaid\ngraph LR\n    subgraph \"Application Progression\"\n        A[chat.go\u003Cbr\u002F>Basic Chat] --> B[read.go\u003Cbr\u002F>+ File Reading]\n        B --> C[list_files.go\u003Cbr\u002F>+ Directory Listing]\n        C --> D[bash_tool.go\u003Cbr\u002F>+ Shell Commands]\n        D --> E[edit_tool.go\u003Cbr\u002F>+ File Editing]\n        E --> F[code_search_tool.go\u003Cbr\u002F>+ Code Search]\n    end\n    \n    subgraph \"Tool Capabilities\"\n        G[No Tools] --> H[read_file]\n        H --> I[read_file\u003Cbr\u002F>list_files]\n        I --> J[read_file\u003Cbr\u002F>list_files\u003Cbr\u002F>bash]\n        J --> K[read_file\u003Cbr\u002F>list_files\u003Cbr\u002F>bash\u003Cbr\u002F>edit_file]\n        K --> L[read_file\u003Cbr\u002F>list_files\u003Cbr\u002F>bash\u003Cbr\u002F>code_search]\n    end\n    \n    A -.-> G\n    B -.-> H\n    C -.-> I\n    D -.-> J\n    E -.-> K\n    F -.-> L\n```\n\nAt the end, you’ll end up with a powerful local developer assistant!\n\n\n\n---\n\n## 🧱 How It Works (Architecture)\n\nEach agent works like this:\n\n1. Waits for your input\n2. Sends it to Claude\n3. Claude may respond directly or ask to use a tool\n4. The agent runs the tool (e.g., read a file)\n5. Sends the result back to Claude\n6. Claude gives you the final answer\n\nWe call this the **event loop** — it's like the agent's heartbeat.\n\n```mermaid\ngraph TB\n    subgraph \"Agent Architecture\"\n        A[Agent] --> B[Anthropic Client]\n        A --> C[Tool Registry]\n        A --> D[getUserMessage Function]\n        A --> E[Verbose Logging]\n    end\n    \n    subgraph \"Shared Event Loop\"\n        F[Start Chat Session] --> G[Get User Input]\n        G --> H{Empty Input?}\n        H -->|Yes| G\n        H -->|No| I[Add to Conversation]\n        I --> J[runInference]\n        J --> K[Claude Response]\n        K --> L{Tool Use?}\n        L -->|No| M[Display Text]\n        L -->|Yes| N[Execute Tools]\n        N --> O[Collect Results]\n        O --> P[Send Results to Claude]\n        P --> J\n        M --> G\n    end\n    \n    subgraph \"Tool Execution Loop\"\n        N --> Q[Find Tool by Name]\n        Q --> R[Execute Tool Function]\n        R --> S[Capture Result\u002FError]\n        S --> T[Add to Tool Results]\n        T --> U{More Tools?}\n        U -->|Yes| Q\n        U -->|No| O\n    end\n```\n\n## 🚀 Getting Started\n\n### ✅ Prerequisites\n\n* Go 1.24.2+ or [devenv](https:\u002F\u002Fdevenv.sh\u002F) (recommended for easy setup)\n* An [Anthropic API Key](https:\u002F\u002Fwww.anthropic.com\u002Fproduct\u002Fclaude)\n\n### 🔧 Set Up Your Environment\n\n**Option 1: Recommended (using devenv)**\n\n```bash\ndevenv shell  # Loads everything you need\n```\n\n**Option 2: Manual setup**\n\n```bash\n# Make sure Go is installed\ngo mod tidy\n```\n\n### 🔐 Add Your API Key\n\n```bash\nexport ANTHROPIC_API_KEY=\"your-api-key-here\"\n```\n\n---\n\n## 🏁 Start with the Basics\n\n### 1. `chat.go` — Basic Chat\n\nA simple chatbot that talks to Claude.\n\n```bash\ngo run chat.go\n```\n\n* ➡️ Try: “Hello!”\n* ➡️ Add `--verbose` to see detailed logs\n\n---\n\n## 🛠️ Add Tools (One Step at a Time)\n\n### 2. `read.go` — Read Files\n\nNow Claude can read files from your computer.\n\n```bash\ngo run read.go\n```\n\n* ➡️ Try: “Read fizzbuzz.js”\n\n---\n\n### 3. `list_files.go` — Explore Folders\n\nLets Claude look around your directory.\n\n```bash\ngo run list_files.go\n```\n\n* ➡️ Try: “List all files in this folder”\n* ➡️ Try: “What’s in fizzbuzz.js?”\n\n---\n\n### 4. `bash_tool.go` — Run Shell Commands\n\nAllows Claude to run safe terminal commands.\n\n```bash\ngo run bash_tool.go\n```\n\n* ➡️ Try: “Run git status”\n* ➡️ Try: “List all .go files using bash”\n\n---\n\n### 5. `edit_tool.go` — Edit Files\n\nClaude can now **modify code**, create files, and make changes.\n\n```bash\ngo run edit_tool.go\n```\n\n* ➡️ Try: “Create a Python hello world script”\n* ➡️ Try: “Add a comment to the top of fizzbuzz.js”\n\n---\n\n### 6. `code_search_tool.go` — Search Code\n\nUse pattern search (powered by [ripgrep](https:\u002F\u002Fgithub.com\u002FBurntSushi\u002Fripgrep)).\n\n```bash\ngo run code_search_tool.go\n```\n\n* ➡️ Try: “Find all function definitions in Go files”\n* ➡️ Try: “Search for TODO comments”\n\n---\n\n## 🧪 Sample Files (Already Included)\n\n1. `fizzbuzz.js`: for file reading and editing\n1. `riddle.txt`: a fun text file to explore\n1. `AGENT.md`: info about the project environment\n\n---\n\n## 🐞 Troubleshooting\n\n**API key not working?**\n\n* Make sure it’s exported: `echo $ANTHROPIC_API_KEY`\n* Check your quota on [Anthropic’s dashboard](https:\u002F\u002Fwww.anthropic.com)\n\n**Go errors?**\n\n* Run `go mod tidy`\n* Make sure you’re using Go 1.24.2 or later\n\n**Tool errors?**\n\n* Use `--verbose` for full error logs\n* Check file paths and permissions\n\n**Environment issues?**\n\n* Use `devenv shell` to avoid config problems\n\n---\n\n## 💡 How Tools Work (Under the Hood)\n\nTools are like plugins. You define:\n\n* **Name** (e.g., `read_file`)\n* **Input Schema** (what info it needs)\n* **Function** (what it does)\n\nExample tool definition in Go:\n\n```go\nvar ToolDefinition = ToolDefinition{\n    Name:        \"read_file\",\n    Description: \"Reads the contents of a file\",\n    InputSchema: GenerateSchema[ReadFileInput](),\n    Function:    ReadFile,\n}\n```\n\nSchema generation uses Go structs — so it’s easy to define and reuse.\n\n---\n\n## 🧭 Workshop Path: Learn by Building\n\n| Phase | What to Focus On                                 |\n| ----- | ------------------------------------------------ |\n| **1** | `chat.go`: API integration and response handling |\n| **2** | `read.go`: Tool system, schema generation        |\n| **3** | `list_files.go`: Multiple tools, file system     |\n| **4** | `bash_tool.go`: Shell execution, error capture   |\n| **5** | `edit_tool.go`: File editing, safety checks      |\n| **6** | `code_search_tool.go`: Pattern search, ripgrep   |\n\n---\n\n## 🛠️ Developer Environment (Optional)\n\nIf you use [`devenv`](https:\u002F\u002Fdevenv.sh\u002F), it gives you:\n\n* Go, Node, Python, Rust, .NET\n* Git and other dev tools\n\n```bash\ndevenv shell   # Load everything\ndevenv test    # Run checks\nhello          # Greeting script\n```\n\n---\n\n## 🚀 What's Next?\n\nOnce you complete the workshop, try building:\n\n* Custom tools (e.g., API caller, web scraper)\n* Tool chains (run tools in a sequence)\n* Memory features (remember things across sessions)\n* A web UI for your agent\n* Integration with other AI models\n\n---\n\n## 📦 Summary\n\nThis workshop helps you:\n\n* Understand agent architecture\n* Learn to build smart assistants\n* Grow capabilities step-by-step\n* Practice using Claude and Go together\n\n---\n\nHave fun exploring and building your own AI-powered tools! 💻✨\n\nIf you have questions or ideas, feel free to fork the repo, open issues, or connect with the community!\n","该项目是一个教你如何构建自己的AI编码助手的工作坊，类似于Roo code, Cline, Amp, Cursor, Windsurf或OpenCode。通过逐步教程，参与者将从创建一个基本的聊天机器人开始，逐渐添加文件读取、代码编辑、命令执行以及代码搜索等高级功能。项目采用Go语言编写，利用Anthropic Claude API来实现与AI的交互。该工作坊适合希望了解如何结合AI技术以提高编程效率的开发者，尤其是那些对构建个人化开发辅助工具感兴趣的用户。无需深厚的AI背景知识，按照步骤操作即可完成学习目标。","2026-06-11 03:44:30","high_star"]