SwiftCodeAgent is a Swift implementation of a Claude Code-style coding agent, built lesson by lesson by following learn-claude-code.
It is a learning and experimentation project for understanding how coding-agent systems are built by rebuilding the runtime in Swift.
The current codebase includes:
- Agent loop with tool calling
- File reading, writing, and editing tools
- Bash execution with permission checks
- Permission modes such as
/mode default,/mode plan, and/mode auto - Persistent memory loading and saving
- Skill loading from
.swiftcodeagent/skills - Session todo tracking
- Persistent task records
- Background task execution and status checks
- Subagent delegation
- Context compaction for long conversations
- Language: Swift 6 with strict concurrency
- LLM integration: AnyLanguageModel
- CLI Framework: swift-argument-parser
- macOS 14+
- Xcode 16+ or Swift 6.2+
You can use either environment variables or a local .env file in SwiftCodeAgent/.
git clone https://github.com/Bruce-pac/SwiftCodeAgent.git
cd SwiftCodeAgent
# Set up your API key and model
cp .env.example .env
# Edit .env with your ANTHROPIC_API_KEY 、ANTHROPIC_BASE_URL and MODEL_ID
swift run SwiftCodeAgentTo leave the interactive session, use exit, quit, or q.
SwiftCodeAgent >> inspect the current directory and tell me what kind of project this is
SwiftCodeAgent >> read Package.swift and summarize the dependencies
SwiftCodeAgent >> /mode plan
SwiftCodeAgent >> create a todo list for refactoring the memory manager
SwiftCodeAgent >> exit
This repository currently covers s01-s13. Remaining topics include:
- Cron scheduler
- Multi Agent Team
- Autonomous agents
- Worktree isolation
- MCP plugin
- Comprehensive integration
