Skip to content
Development
Command

/generate-idl-client

Generate a typed client from an Anchor or Shank IDL (Codama or Anchor TS)

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

Command definition

generate-idl-client.md
description: "Generate a typed client from an Anchor or Shank IDL (Codama or Anchor TS)"

Generate or refresh the client for a program. `$ARGUMENTS` can name the program, the IDL path, or the output directory.

Pipeline and repo layout: [idl-codegen.md](../skills/ext/solana-dev/skills/solana-dev/references/idl-codegen.md). Using the generated client: [kit/codama.md](../skills/ext/solana-dev/skills/solana-dev/references/kit/codama.md).

Choose the generator

  • Codama (default): renders a Kit-native TypeScript client, plus a Rust client if wanted, from an Anchor or Shank IDL. Use it for new clients, `@solana/kit` frontends, and every native or Pinocchio program.
  • Anchor TS client (`@anchor-lang/core`): only when the app already builds on `Program`/`AnchorProvider`. There is nothing to generate: `anchor build` writes `target/idl/<name>.json` and `target/types/<name>.ts`, and `new Program(idl as MyProgram, provider)` takes the address from `idl.address`.
  • Rust client or CPI from another Anchor program: `declare_program!(<name>)` reads `idls/<name>.json`. For a deployed program, `anchor idl fetch -o idls/<name>.json <PROGRAM_ID>` (Anchor 1.x reads the IDL from Program Metadata).

Steps

1. Build the IDL from current code:

  • Anchor: `NO_DNA=1 anchor build` writes `target/idl/<name>.json`.
  • Native or Pinocchio with Shank macros: `cargo install shank-cli`, then `shank idl -r programs/<name> -o idl` (`-p <PROGRAM_ID>` sets the address). Check that the IDL has `metadata.origin: "shank"`: Codama reads Shank IDLs through its Anchor adapter and uses that field to pick 1-byte discriminators.

2. Generate with Codama:

  • Anchor CLIs with the `codama` subcommand (check `anchor codama --help`): `anchor codama generate -l js -p clients target/idl/<name>.json`, or set `[clients] auto = true` and `js = true` in Anchor.toml to regenerate on every `anchor build`.
  • Codama CLI: `npx codama init` (asks for the IDL path and renderers, writes `codama.json`, installs `@codama/renderers-js` and, for Anchor or Shank IDLs, `@codama/nodes-from-anchor`), then `npx codama run js` (or `--all`).
  • Script form, if the project already has one: `createFromRoot(rootNodeFromAnchor(idl)).accept(renderVisitor(outDir))`, with `createFromRoot` from `codama` and `renderVisitor` from `@codama/renderers-js`.

3. Typecheck the consumers (`npx tsc --noEmit`) and run the tests that use the client. 4. Commit generated code when consumers should not have to run codegen; otherwise wire generation into the build or CI. Regenerate after every instruction or account change.

Output

IDL source and path, generator, output directory, instruction and account counts, typecheck result.

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