---
title: "Building on Solana with AI: practical guides · Barestate"
description: "Practical guides for building, testing and debugging Solana programs with AI coding agents: tests that decide when the work is done, local chains, toolchain versions, error decoding and keypair safety."
url: https://barestate.xyz/solana
---

# Building on Solana with AI: practical guides

Short answer

To build Solana programs with AI reliably, make a test decide when the work is done, run it on a local chain, give the model Solana references and your real toolchain versions, decode errors from the program’s own tables, and keep funded keys away from anything the agent can run. These guides show each step with standard Solana tools first, then with Oh My Sol.

Who it’s for

Solana developers using Claude Code, Codex, Cursor or Oh My Sol who want AI-written programs that build, pass tests and do not touch their keys.

Last checked

November 16, 2026, against Oh My Sol 0.1.0

## How do I get an AI agent to write and test a Solana program?

- [Build and test an Anchor program with AI](https://barestate.xyz/solana/build-and-test-an-anchor-program-with-ai): Scaffold with anchor init, write the tests first, and let the test command decide when the agent is done.
- [Make a coding agent work until your Solana tests pass](https://barestate.xyz/solana/make-a-coding-agent-work-until-solana-tests-pass): Let a check, not the model, decide when the work is done: a Stop hook, CI, or Oh My Sol’s /goal.
- [Test a Solana program locally with an AI agent](https://barestate.xyz/solana/test-a-solana-program-locally-with-an-ai-agent): LiteSVM and Mollusk for fast tests, Surfpool for end-to-end runs, and never a funded mainnet key.

## What does the model need to write working Solana code?

Give it something to check against: Solana references, the versions your project really uses and the packages it has installed.

- [Get working Solana code from an AI coding agent](https://barestate.xyz/solana/get-working-solana-code-from-an-ai-agent): Pin your versions, give the agent Solana references and the installed packages, and test on a local chain.
- [Fix Anchor, Agave and platform-tools version mismatches](https://barestate.xyz/solana/fix-anchor-agave-platform-tools-version-mismatches): Line up the Anchor CLI, anchor-lang, the Solana CLI, platform-tools and Cargo.lock.

## How do I debug a failure with AI?

- [Decode Solana custom program errors](https://barestate.xyz/solana/decode-solana-custom-program-errors): Convert the hex code, find the program that failed, and look the number up in its errors or your IDL.
- [Debug a failed Solana transaction with AI](https://barestate.xyz/solana/debug-a-failed-solana-transaction-with-ai): Get the full logs, read the code, check compute units, and give the agent the logs and the IDL.

## How do I keep my keys safe from the agent?

- [Keep AI agents away from your Solana keypair](https://barestate.xyz/solana/keep-ai-agents-away-from-your-solana-keypair): Keep mainnet keys off the machine, sandbox the agent, and test with throwaway keys on a local chain.

## Which AI coding tool should I use for Solana?

OMS beats both Codex CLI and Claude Code on Solana Bench and on fresh Solana tasks. The [comparison pages](https://barestate.xyz/compare) show the numbers and set out how OMS differs from Claude Code, Codex CLI and other Solana AI tools.

- [Move from Claude Code or Codex CLI to Oh My Sol](https://barestate.xyz/solana/switch-from-claude-code-or-codex-to-oh-my-sol): Keep your Claude or ChatGPT subscription and your repo; your test command becomes the check.

## Frequently asked questions

Can AI write Solana programs?

Yes. Models write Anchor and native Rust programs well when the setup around them is right: Solana references and your real toolchain versions to work from, decoded errors, a local chain to run the program on, and a test that decides when the work is done.

What is the most important rule when using an AI agent on Solana?

Let a test, not the model, decide when the work is done, and run it on a local chain. The second rule is to keep funded keys away from anything the agent can run.

Do these guides only work with Oh My Sol?

No. Each guide first shows how to do the job with standard Solana tools (Anchor, the Solana CLI, Surfpool, LiteSVM, Mollusk) and any coding agent, then shows how Oh My Sol does it.

What is Oh My Sol?

Oh My Sol (OMS) is a terminal harness from Barestate for building, testing and debugging Solana programs with the model you already use, such as Codex or Claude Code. It gives the model Solana references, error decoding and toolchain checks, runs your program on a local Surfpool chain, works in a Git worktree per task, and closes a task only when your requirements pass.

Which AI coding tool is best for Solana?

For writing and testing Solana programs, OMS beats both Codex CLI and Claude Code. 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, and on fresh Solana tasks it passed 96% of runs against 76% for Codex CLI with GPT-6.1 Sol. The comparison pages cover the other tools.

## 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)
