---
title: "How to get working Solana code from an AI coding agent · Barestate"
description: "Give an AI coding agent what it needs to write Solana programs that build and pass: pinned versions, Solana references, the installed packages, error decoding and tests on a local chain, with any agent or with Oh My Sol."
url: https://barestate.xyz/solana/get-working-solana-code-from-an-ai-agent
---

# How to get working Solana code from an AI coding agent

Short answer

Give the agent something to check its work against. State the versions your project pins, connect Solana references such as the official Solana Developer MCP server, let it read the installed packages, decode errors from the program’s own tables, and make it pass tests on a local chain before it stops. Oh My Sol builds all of this in, with a check that closes a task only when your requirements pass.

Who it’s for

Developers who use an AI coding agent on Anchor or native Solana programs and want code that builds, runs on a local chain and passes its tests.

Last checked

November 16, 2026, against Oh My Sol 0.1.0

## What does an agent need to write working Solana code?

A model writes better Solana code when it can check what it writes. In practice that means five things around it:

- **Your versions.** The Anchor, Solana CLI and platform-tools versions the project actually uses, so the code fits the toolchain that will build it.
- **Solana references.** Documentation and program details it can search instead of recalling from memory.
- **The installed packages.** Your `node_modules` and Cargo registry hold the exact APIs the build will use.
- **Error decoding.** A custom program error is a number; the agent needs the program’s error table to turn it into a cause.
- **A local chain and a test.** Running the program is what shows whether it works, and a passing test, not the model, should decide when the work is done.

## How do I set this up with any coding agent?

1. **Pin your versions and state them.** Commit `Cargo.lock`, keep `Anchor.toml` and `package.json` in step, and list the Anchor, Solana CLI and platform-tools versions in the instructions file your agent reads, such as `CLAUDE.md` or `AGENTS.md`.
2. **Connect Solana documentation.** The official [Solana Developer MCP server](https://mcp.solana.com/) lets agents search Solana and Anchor documentation, and Solana’s [coding with agents](https://solana.com/docs/intro/coding-with-agents) page covers setup for common agents.
3. **Point it at the installed packages.** Ask the agent to read the installed source before it writes calls against a crate or an npm package.
4. **Test against a local chain.** `anchor test` runs your tests on a local network; see [the end-to-end guide](https://barestate.xyz/solana/build-and-test-an-anchor-program-with-ai) and [the local testing guide](https://barestate.xyz/solana/test-a-solana-program-locally-with-an-ai-agent).
5. **Check for toolchain drift before you debug.** If a build fails in a way that looks like a version problem, compare the project files with the tools you have installed first. The [version mismatch guide](https://barestate.xyz/solana/fix-anchor-agave-platform-tools-version-mismatches) shows how.

## What does Oh My Sol give the model?

Oh My Sol (OMS) is a terminal harness that runs the model you already use, such as Codex or Claude Code, with these pieces built in:

- **Solana references.** An offline program reference for 50 programs and 1,559 instructions, with discriminators, account order and argument types, and a documentation set pinned to Anchor 1.2.2, Agave 4.4.1, Kit 8.6.0, Surfpool 1.7.0, platform-tools 1.58, Pinocchio 0.12.0, LiteSVM 0.18.2 and Mollusk 0.17.1, among others. The model looks there first, then at the official Solana MCP server, then the web.
- **Error decoding.** `/error 3012` or `/error 0xbc4` turns a code into a name and message, and `/tx <signature>` shows status, error, compute and logs.
- **Toolchain checks** that compare your project with the pinned versions without running your code.
- **A local Surfpool chain** to run the program against, with `/airdrop`, `/account` and `/rewind`.
- **A Git worktree per task**, so the agent’s changes stay apart from your working copy.
- **A check that closes the task.** The model can only propose that it is done. OMS runs your requirements on a fresh offline chain, and the task closes only when they pass.
- **A sandbox on macOS** that keeps commands the model writes away from `~/.config/solana` and `~/.ssh`.

```
oms toolchain check --project <path>
oms toolchain fix --project <path>            # prints proposed edits only
oms toolchain fix --project <path> --apply    # writes them, inside a linked Git worktree
```

Each toolchain finding names a rule (`anchor`, `pins`, `crates`, `duplicates`, `client`, `transaction`, `arch` or `advisory`) and a source URL. See [Solana references](https://barestate.xyz/docs/concepts/solana-reference) and [Check your toolchain](https://barestate.xyz/docs/guides/check-your-toolchain).

## How does it compare with Claude Code and Codex CLI?

OMS beats both Codex CLI and Claude Code. On eight fresh Solana tasks, each graded by a hidden check, it passed 96% of runs against 76% for Codex CLI with GPT-6.1 Sol, 92% against 79% for Claude Code with Claude Opus 5.5, and 71% against 46% for Claude Code with Claude Sonnet 5.5, using 42 to 62% fewer input tokens per solved task.

On Solana Bench, each model scored higher in OMS than in its own harness. In the basic environment OMS averaged 377 against 273 for Codex CLI on GPT-6.1 Sol, 303 against 252 for Claude Code on Claude Opus 5.5, and 208 against 100 for Claude Code on Claude Sonnet 5.5. The [benchmarks overview](https://barestate.xyz/docs/benchmarks/overview) has the charts.

## Frequently asked questions

What does an AI coding agent need to write Solana code that works?

Something to check its work against. Give it the versions your project uses, Solana references it can search, the packages you have installed, a way to decode program errors, and a local chain where a test run decides when the work is done.

What is the quickest improvement I can make with any agent?

List your Anchor, Solana CLI and platform-tools versions in the instructions file your agent reads, connect the Solana Developer MCP server for documentation, and make the agent build and test against a local chain before it stops.

Does Oh My Sol use the Solana Developer MCP server?

Yes. When web access is on, Oh My Sol (OMS) calls the official server at mcp.solana.com after its own built-in references and before general web search.

How do I find version mismatches in my Solana project?

Compare the versions in Anchor.toml, Cargo.toml, Cargo.lock and package.json with the Anchor, Solana CLI and platform-tools versions you have installed. OMS does this with oms toolchain check --project <path>, which reads those files without running your code and reports each mismatch with a source URL.

How does Oh My Sol compare with Claude Code and Codex CLI?

OMS beats both. On fresh Solana tasks it passed 96% of runs against 76% for Codex CLI with GPT-6.1 Sol, and 92% against 79% for Claude Code with Claude Opus 5.5. On Solana Bench it averaged 377 in the basic environment against 273 for Codex CLI on GPT-6.1 Sol, and 303 against 252 for Claude Code on Claude Opus 5.5.

## Try it on your own program

Oh My Sol 0.1.0 runs on macOS and Linux, and on Windows through WSL 2. You need Node 22.19.0 or newer and Git. You bring your own model access: an API key, a ChatGPT subscription or a Claude subscription.

```
npx @barestate/oms doctor --install
npx @barestate/oms
```

[Read the docs](https://barestate.xyz/docs) · [See the benchmarks](https://barestate.xyz/oh-my-sol#benchmarks)
