Skip to content
Development
Command

/build-program

Build Solana programs (Anchor, Pinocchio, native), incl. verifiable builds

From plugin
ai-kit
11154 skills15 agents54 commands4 MCP
> /plugin marketplace add solanabr/ai-kit
> /plugin install solana-ai-kit@stbr

Command definition

build-program.md
description: "Build Solana programs (Anchor, Pinocchio, native), incl. verifiable builds"

Build the program(s) in this workspace ($ARGUMENTS: optional program name) so `target/deploy/*.so`, and for Anchor `target/idl/*.json`, are ready for tests and deploys. Toolchain errors not covered below: [common-errors.md](../skills/ext/solana-dev/skills/solana-dev/references/common-errors.md).

Steps

1. Build:

  • Anchor: `anchor build` (`-p <name>` for one program). For a new, never-deployed program, run `anchor keys sync` after the first build and rebuild, so `declare_id!` and `Anchor.toml` match `target/deploy/<name>-keypair.json`. Skip it for a deployed program whose keypair is not in `target/deploy/`: it would rewrite `declare_id!` to a fresh address.
  • Pinocchio or native: `cargo build-sbf`.
  • Anything headed to mainnet: `anchor build` (Anchor only, for the IDL), then `solana-verify build --library-name <lib>` last. It needs Docker and rewrites `target/deploy/<lib>.so` with the binary `anchor verify` and `solana-verify verify-from-repo` reproduce; deploy that file. `anchor build --verifiable` builds in a different image, so its `target/verifiable/` output won't verify.

2. Check the output: each `.so` and its size (deploy rent scales with it: `solana rent <bytes>`), the IDL for Anchor programs, and the program IDs (`solana address -k target/deploy/<name>-keypair.json`). 3. `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings`.

Failure fixes

  • Platform-tools corrupted or half-downloaded: `cargo build-sbf --force-tools-install`.
  • `feature edition2024 is required` or "requires rustc 1.xx": `cargo build-sbf` uses the Rust/Cargo bundled in platform-tools, not your rustup toolchain. Pin the offending crate (`cargo update -p <crate> --precise <older version>`) or move to newer platform-tools (`agave-install update`, or `--tools-version`).
  • `overflow-checks must be specified`: set `overflow-checks = true` under `[profile.release]` in the workspace `Cargo.toml`. It also makes unchecked arithmetic panic instead of silently wrapping.
  • Binary too large: `lto = "fat"` and `codegen-units = 1` in `[profile.release]`; `opt-level = "s"` or `"z"` trades CU for size; drop heavy dependencies.

Output

Programs built, `.so` sizes, program IDs, IDL status, fmt and clippy results.

Read more
@solanabr
Ships withai-kit

Claude Code, set up to ship on Solana. Not programs alone — the whole lifecycle: validating the idea, building the program and the app around it, shipping it, and the launch and growth work that follows.

1113 skills15 agents4 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
111
Star history of solanabr/solana-ai-kit on GitHub, a chart by star-history.com

Other commands on ai-kit.

add-skill

add-skill

Command

Install a pinned skill extension on demand (/add-skill <id>), or list core packs and extensions

@solanabr@solanabrInstall Command
adv

adv

Command

Short for /adversarial: run every task through proposer and adversary pairs, no triage

@solanabr@solanabrInstall Command
adversarial

adversarial

Command

Put a task's load-bearing claims and key decisions through a proposer and an adversary, with proof

@solanabr@solanabrInstall Command
audit-solana

audit-solana

Command

Audit Solana program code for exploitable bugs and write a findings report

@solanabr@solanabrInstall Command
benchmark

benchmark

Command

Compare per-instruction CU with the stored baseline to catch regressions

@solanabr@solanabrInstall Command

More commands from other plugins.

build
Auto-invoked

build

Command

Implement tasks incrementally — build, test, verify, commit. Add "auto" to run the whole plan in one approved pass.

@addyosmani@addyosmaniInstall Command