coding-agent-patterns
Safety Rules
参见 _shared/core/safety-rules.md — 所有安全规则从共享层加载,避免跨技能重复维护。
Quick Commands
| Command | Description |
|---|---|
/agent-patterns |
View coding agent patterns (core loop, context management, tool safety, multi-provider, memory systems) |
Coding Agent Development Patterns
Core patterns distilled from Claude Code (70k stars), Codex (62k), Cline (58k), Aider (41k), and OpenCode (114k).
The Core Loop: while(true)
All AI coding agents share the same fundamental loop. The loop follows the pattern: ask LLM if it needs tools, use them, feed results back, and repeat until done. The implementation builds context with tools and conversation history, calls the LLM with messages and tool definitions, checks for tool calls and returns content if none, executes tools and appends results to history, then loops back with tool results.
Core Tools: All agents have six fundamental tools. The read tool reads file contents. The write tool creates or overwrites files. The edit tool performs precise string replacement in files. The bash tool executes shell commands. The glob tool finds files by pattern. The grep tool searches file contents. A minimal viable agent requires approximately 1000-2000 lines with these six tools plus the loop.