Swift Coding Agent
A staged Swift rebuild of a Claude Code-style coding agent, built to find the minimum architecture the job needs.
- Source repo
- ivan-magda/swift-coding-agent
- Stars
- ★ 185
- Last updated
- 5mo ago
- FARS reviewed
- Nov 23, 2026
- License
- MIT
- Primary language
- Swift
- FA score
- 39/100 · Major gaps
At a glance
- How it runs
- Works with
- Platform-specificClaude API
- Cost
- Free software; you pay for model usage
- Setup effort
- Medium · a few setup steps
- You'll need
- Typical use
- Swift developers who want to read agent internals stage by stage using the git tags as a syllabus
- Not a fit if
- Teams wanting a mature, ready-to-use coding assistant
- Users expecting a drop-in Claude Code replacement
- Developers not comfortable with Swift and SwiftPM tooling
- Website
- ivanmagda.dev ↗ set on GitHub
- Maintenance
- Commits in the last 6 monthslast commit 2026-06-26
- Source review
- 39/100 · Major gaps 2 safety controls not found
What does this agent do, and when should you use it?
swift-coding-agent is a from-scratch implementation of a Claude Code-style CLI coding agent written in Swift 6.2, built one stage at a time to study which design choices actually matter. It is a two-target Swift Package Manager project: Core is a library holding the API client, shell executor, agent loop and tools, while the CLI target produces an executable named agent. The agent talks to POST https://api.anthropic.com/v1/messages over raw HTTP via AsyncHTTPClient, runs on macOS and Linux, and executes shell commands with Foundation Process. Git tags mark nine stages split into core loop mechanics (bash, file tools, todo reminders) and product mechanics (subagents, skill loading, three-layer context compaction, a file-based task DAG, background tasks). The author states it is deliberately not a Claude Code clone or production tool; it is MIT licensed.
Running swift run agent starts an async loop: it appends the user query to messages, builds an APIRequest with model, systemPrompt, messages and toolDefinitions, and calls createMessage against the Anthropic Messages API. If stopReason is toolUse, it walks the response content for tool_use blocks, runs each through executeTool (bash, read_file, write_file, edit_file and later-stage tools), appends the tool_result blocks as a user message and iterates; otherwise it returns the response text. Shell execution uses Foundation Process, transport and streaming SSE use AsyncHTTPClient on SwiftNIO, and background stages use Swift Task {} with an actor-based notification queue. Additional stages inject todo reminders, run subagents with fresh context, load .md skill files as tool results, apply micro/auto/manual context compaction, and provide file-based task CRUD with a dependency DAG. The loop body itself never changes — only the tool handler dictionary and pre-call injection points grow.
- Swift developers who want to read agent internals stage by stage using the git tags as a syllabus
- Engineers standing up a self-hosted CLI agent on macOS or Linux that calls the Anthropic API directly
- Teaching or writing about tool_use and tool_result protocol with a minimal, readable loop
- Researchers who want to import the Core library into their own Swift project
- Experimenters comparing context-compaction and task-state designs across stages
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Environment variables
ANTHROPIC_API_KEYMODEL_ID- Config files
.env.example.env
How do you install or deploy this agent?
You need a Swift 6.2 toolchain, network access to api.anthropic.com, and an Anthropic API key.
git clone https://github.com/ivan-magda/swift-coding-agent.git
cd swift-coding-agent
cp .env.example .env
# edit .env with your ANTHROPIC_API_KEY and MODEL_ID
swift buildHow do you use this agent?
After the build, launch the CLI executable named agent:
swift run agentThe program reads ANTHROPIC_API_KEY and MODEL_ID from .env, sends requests to POST https://api.anthropic.com/v1/messages, and loops between tool calls and final text. Check out git tags (00-bootstrap, 01-agent-loop, … 08-background-tasks) to compare each stage's implementation. Treat it as staged experimental code rather than a production utility.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
Makes outbound requests; verify telemetry settings and model data routing on private repos.
FARS trust-control audit
- confirmation before acting — Turn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
- rollback or recovery path — Back up first, or work on a git branch or snapshot, so its changes can be undone.
What are this agent's strengths and limitations?
- One mechanism per git-tagged stage makes the architecture readable in order
- Fixed loop with variable tools; the executeTool boundary and injection points are easy to modify
- Core library separated from the CLI executable, so Core can be reused as a SwiftPM dependency
- AsyncHTTPClient provides cross-platform HTTP and streaming SSE on both macOS and Linux
- Covers real product mechanics — context compaction, subagents, skill loading, task DAGs — not just a demo
- Talks to a single endpoint, the Anthropic Messages API, with no multi-provider abstraction
- Requires your own ANTHROPIC_API_KEY and MODEL_ID, billed per use
- Depends on the Swift 6.2 toolchain, a heavy lift for non-Swift teams
- Author states it is not a Claude Code clone and not production IDE tooling; gaps are intentional
- Configuration surface is limited to the two .env values; no other repository guidance ships in the repo
How does this agent compare with similar options?
The project explicitly uses Claude Code as its reference model and tries to reproduce its tool surface and loop, and the README notes that most coding agents lean on larger orchestration layers; it does not name specific competing projects.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Swift Coding Agent This agent | 39 · Major gaps | CLIFree + model costs | ★ 185 | 5mo ago | Swift | Claude API |
| 3code Economical Coding Agent | 59 · Major gaps | CLIFree + model costs | ★ 123 | 2d ago | Nim | OpenAI API |
| rpi: Rust Coding-Agent Runtime | 71 · Some gaps | CLIFree + model costs | ★ 298 | today | Rust | OpenAI API · Claude API |
| Claude Code From Scratch | 62 · Some gaps | CLIFree + model costs | ★ 2.8k | 14d ago | Python | OpenAI API · Claude API |
How does FollowAgents rate this agent?
Why each dimension lost points
README claims path safety at stage 02 but no source is in the packet to verify least-privilege enforcement; no user confirmation mechanism is described; data flow only names the Anthropic Messages API without stating what content is sent; API key via .env but no sensitive-data handling detail; AsyncHTTPClient dependency has no pinned version evidence; bash tool and file writes are external effects with no rollback or undo; attribution limited to Anthropic doc references. Each deducted for missing or merely asserted evidence.
The README agent-loop code is self-consistent with the architecture description and CI covers macOS/Linux build and test, so self-consistency scores 2; dependency availability only lists AsyncHTTPClient and Swift 6.2 with no Package.resolved evidence; failure messages are not shown in the sample.
README clearly frames the project as a learning/exploration tool with explicit Non-Goals, so scenario boundaries are clear; trigger precision (when tools fire, skill-load conditions) is only briefly described in the example skill with no system-prompt or tool-definition source to corroborate; environment fit is stated as macOS/Linux and backed by CI.
README is well-structured with complete install steps, Non-Goals as known limitations, and a full MIT license; but versioning relies only on git tags with no changelog, naming stability is unevidenced, examples are a single placeholder skill, and maintenance responsibility is unclear (publisher unverified).
As a teaching project output usability is limited; README shows the core loop but no complete runnable artifact evidence; marginal value is architectural explanation rather than a production tool; cost-benefit is moderate given a self-supplied API key and incomplete features.
README claims are mostly design intent without source cross-corroboration; the roadmap-to-tag mapping cannot be checked in the sample; facts and inferences (e.g. 'Claude Code wins through restraint') are mixed in the README without separation.
- Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
- Not found in source: rollback or recovery pathBack up first, or work on a git branch or snapshot, so its changes can be undone.
- Core source is absent from the sample, so least-privilege, path-safety, and failure-handling claims cannot be statically verified.
- No user confirmation or rollback mechanism; bash and file writes may cause irreversible side effects.
- Dependency versions are not pinned, raising build reproducibility concerns.
- Publisher identity is unverified; maintenance responsibility and update path are unclear.
FAQ
Does it cost anything to run?
Can it replace Claude Code?
Can I plug in OpenAI or other models?
Will it modify files or run commands on my machine?
Which operating systems are supported?
Is Swift Coding Agent open source?
Is Swift Coding Agent safe to use?
Is Swift Coding Agent still maintained?
Who makes Swift Coding Agent?
What is Swift Coding Agent's official website?
Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.