swift-coding-agent CLI

Educational Swift CLI agent in the spirit of Claude Code: tool loop, subagents, skills, context compaction and tasks

  • 184 ★ on the repository
  • Last commit
  • MIT
CLI

Extended access

Why this level

  • The agent runs shell commands chosen by the model, and the README does not describe confirmation before execution
  • The Anthropic key lives in a .env file and requests with project contents go to the Anthropic API
All reasons and checks
Needs a VPN

ivan-magda/swift-coding-agent

Install

Manual install

git clone https://github.com/ivan-magda/swift-coding-agent.git

Then copy .env.example to .env, set ANTHROPIC_API_KEY and MODEL_ID, and run swift build and swift run agent.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • The agent runs shell commands chosen by the model, and the README does not describe confirmation before execution
  • The Anthropic key lives in a .env file and requests with project contents go to the Anthropic API

This is third-party code. Review the repository files before installing.

What it does

The repository rebuilds a Claude Code-style agent in Swift 6.2 step by step to find out which design choices make a coding agent work. The executable is called agent: it sends requests straight to the Anthropic Messages API and runs a single loop where the model calls tools and the results go back into the conversation. Each stage adds one mechanism and carries a git tag: a loop with bash, read_file, write_file and edit_file tools with path safety, todo tracking with reminders, subagents with fresh context, skill loading from Markdown files, three-layer context compaction, a file-based task system with a dependency graph and background tasks. Each stage has a post in a nine-part series.

Who it is for. Swift developers who want to study how a coding agent works from source and build their own without a ready-made framework.

Good fit when

  • You want to see how the tool_use and tool_result loop in the Anthropic Messages API works in real code
  • You want to replay the repository tags and see one added mechanism per stage
  • You need a Swift agent as a base: the API client, command execution and task manager are already written
  • Your team is deciding whether subagents and context compaction are worth it and wants a compact working example

Not a fit when

  • You need a working daily-driver tool: the author calls the project educational and not a replacement for Claude Code
  • You need IDE integration or several providers: the agent talks only to the Anthropic API
  • You do not work with Swift: more popular educational implementations exist for Python or TypeScript

Example request

Find all calls to the deprecated loadConfig function in the project, replace them with readConfig and show which files changed

Limitations

  • The author says it is not a Claude Code clone, not a multi-agent framework and not production tooling; the gaps are deliberate.
  • It needs Swift 6.2, an ANTHROPIC_API_KEY and a model ID in the .env file.
  • The Anthropic API is unavailable from Russia, so requests to it will not go through without extra arrangements.
  • The last commit is dated June 2026, and the project is not evolving further.
  • The README does not describe confirmation before commands run, so use a separate folder or a sandbox.

How to disable. There is no install: delete the cloned repository folder and the .env file with the key. Revoke the API key in the Anthropic console if needed.

FAQ

How do I run swift-coding-agent?

Clone the repository, copy .env.example to .env, fill in ANTHROPIC_API_KEY and MODEL_ID, then run swift build and swift run agent. It works on macOS 10.15 or newer and on Linux.

How is it different from Claude Code?

It is an educational staged rebuild with a small toolset. The author does not aim to copy the whole product and calls the gaps deliberate.

Where should I start reading the code?

Start with Sources/Core/Agent.swift, where the loop lives, and the nine-part series on the author's site. Tags such as 01-agent-loop take you to a given stage.

Does it support skills?

Yes, from stage five skills from Markdown files are loaded as tool results. An example sits in skills/example/SKILL.md.

Which tools does the agent have?

Shell commands, reading, writing and editing files with path safety, a todo list, subagents, skill loading and background tasks. The set grows by stage, and the full list is visible in the repository tags.

Discussion

No questions or reviews yet.

CLI tools

A teaching terminal coding agent in Python, built as a "nanoGPT for agents": read it, take it apart and fork it

CLIBroad access1.9KRepository stars

A TypeScript terminal agent: streaming REPL, OpenAI-compatible and Anthropic models, plan mode and edit rollback.

CLIBroad access110Repository stars

An open coding agent for the terminal, browser and desktop that works with models from OpenAI and Claude to Ollama

CLIBroad access364Repository stars

AI Builder Club Skills

AI Builder Club — Skills

A Claude Code plugin marketplace to make a repo agent-ready and run compounding agent loops

PluginBroad access1.3KRepository stars

A local-first AI agent running on your own machine via llama.cpp that drives a browser, edits files, runs approved commands and remembers context across session

CLIBroad access3.6KRepository stars

The squads CLI runs teams of agents defined in markdown files in git: a lead briefs, workers act, a verifier checks.

CLIBroad access56Repository stars

Comparison with similar tools

Cards that share the main search query, and how they differ.

ToolOfficialRepository starsMain difference
swift-coding-agent (this card)no184
Claude Codeno155,534Claude Code is a finished product, while this is a compact educational rebuild with one mechanism per stage
Aiderno50,089Aider is for everyday git code editing, while this agent exists to study how the loop works

README in short

The README explains the idea: test whether a small set of good tools and thin orchestration works as well as heavy layers. It then shows the loop code, a nine-stage roadmap in two phases, the Core and cli package architecture, a list of what the project is not, the tech stack and run steps.

README badge

Report a problem