This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Shank is a collection of Rust crates that extract Interface Definition Language (IDL) files from Solana programs using macro annotations. The generated IDL is consumed by tools like solita to generate TypeScript SDKs for Solana programs.
This is a Rust workspace containing 6 main crates:
- shank - Top-level crate that exports all macros, entry point for users
- shank-macro - Provides derive macros (
ShankAccount,ShankInstruction,ShankType, etc.) - shank-macro-impl - Core implementation of the derive macros and parsing logic
- shank-idl - Processes Rust source files to extract IDL from shank annotations
- shank-render - Generates Rust code (like PDA functions) from annotations
- shank-cli - Command-line tool that orchestrates IDL extraction
The workflow: Users annotate their Solana program structs/enums with shank macros → shank-cli analyzes the source code → produces JSON IDL → consumed by code generators.
cargo test # Run all tests across workspace
cargo build # Build all crates
cargo build --release # Release buildcargo install shank-cli # Install CLI globally
shank idl # Extract IDL to ./idl/ directory
shank idl -o <dir> # Extract IDL to custom directory
shank idl -r <crate-root> # Specify program crate rootcargo test && cargo release <major|minor|patch> # Dry run
cargo release <major|minor|patch> --execute # Execute release#[derive(ShankAccount)]- Marks account structs with optional#[seeds]for PDA generation#[derive(ShankInstruction)]- Marks instruction enums with#[account]attributes#[derive(ShankType)]- Marks custom types for IDL inclusion#[derive(ShankBuilder)]- Generates instruction builders#[derive(ShankContext)]- Generates account context structs
#[padding]- Marks field as padding in IDL#[idl_type("TypeName")]- Overrides field type in IDL#[idl_name("name")]- Renames field in IDL while keeping Rust field name#[skip]- Excludes field from IDL entirely
Test files are organized in each crate's tests/ directory with fixture files demonstrating expected behavior. Tests verify both macro expansion and IDL generation accuracy.
- Uses Rust 2018 edition
- Release configuration in
release.toml - Only releases from
masterbranch - Uses
rustfmt.tomlfor consistent formatting - Heavy use of
synandquotefor macro implementation