Solana Program Development

VerifiedSafe

Guides AI assistants in writing, testing, and deploying Solana programs using native Rust or the Anchor framework. It helps with account validation, PDAs, CPIs, and testing with tools like LiteSVM, bankrun, or Mollusk.

Sby Skills Guide Bot
DevelopmentIntermediate
906/2/2026
Claude CodeCursorWindsurfCopilotCodex
#solana#anchor#rust#blockchain#smart-contracts

Recommended for

Our review

This skill guides AI assistants in writing, testing, and deploying Solana programs (smart contracts) using native Rust and the Anchor framework.

Strengths

  • Comprehensive coverage of the Solana program lifecycle from scaffolding to deployment.
  • Emphasis on best practices (account validation, PDAs, error handling, compute unit optimization).
  • Includes templates for both Anchor and native Rust, plus testing strategies with LiteSVM and bankrun.
  • Supports advanced patterns like CPIs using declare_program!.

Limitations

  • Does not replace deep understanding of Solana's account model.
  • Reference files (anchor-programs.md, etc.) must be included in the knowledge base for full effectiveness.
  • Does not cover SPL token design or interactions with specific third-party programs.
When to use it

Best for building a new Solana program, implementing complex instructions, or debugging on-chain errors.

When not to use it

Avoid if you are working on an existing Solana project with an unconventional architecture that requires contextual knowledge beyond this guide.

Security analysis

Safe
Quality score80/100

The skill provides instructional guidance for writing Solana programs, using code examples and patterns. It does not instruct the AI to execute any commands that could cause harm, nor does it contain obfuscated or malicious content. All operations are purely code-authoring advice.

No concerns found

Examples

Basic Anchor program for token staking
Write an Anchor program for a token staking system where users can stake SPL tokens and earn rewards. Include instructions to stake, unstake, and claim rewards. Use PDA for the staking account.
Debugging on-chain error
I'm getting a 'Program failed to complete' error when calling my Solana program. Can you help me debug it? Here's the instruction code...
Deploying to devnet
Guide me through deploying my Anchor program to Solana devnet, including building the BPF and using the Solana CLI to deploy.

Solana Program Development

Description

Guides AI assistants in writing, testing, and deploying Solana programs (smart contracts) using both native Rust and the Anchor framework.

When to Use

  • Writing a new Solana program (on-chain code)
  • Implementing program instructions, accounts, state
  • Working with PDAs, CPIs, or system instructions
  • Testing programs with LiteSVM, bankrun, or Mollusk
  • Deploying or upgrading programs
  • Debugging on-chain program errors

Instructions

For New Programs

  1. Ask if the user prefers Anchor (recommended) or native Rust
  2. Determine the program's purpose and required accounts
  3. Scaffold the project structure
  4. Implement instruction logic with proper validation
  5. Write tests
  6. Guide deployment

Key Principles

  • Always validate all accounts — check ownership, signers, writable
  • Use PDAs for program-derived state (avoid storing keypairs)
  • Handle errors explicitly with custom error enums
  • Minimize compute units — Solana has per-instruction limits (200k default, 1.4M max per tx)
  • Consider rent exemption for all account creation
  • Use declare_program! (Anchor 0.30+) for CPI to avoid dependency hell

Reference Files

Common Patterns

Anchor Program Skeleton

use anchor_lang::prelude::*;

declare_id!("YOUR_PROGRAM_ID");

#[program]
pub mod my_program {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>, data: u64) -> Result<()> {
        ctx.accounts.my_account.data = data;
        ctx.accounts.my_account.authority = ctx.accounts.authority.key();
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(
        init,
        payer = authority,
        space = 8 + MyAccount::INIT_SPACE,
        seeds = [b"my_account", authority.key().as_ref()],
        bump,
    )]
    pub my_account: Account<'info, MyAccount>,
    #[account(mut)]
    pub authority: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[account]
#[derive(InitSpace)]
pub struct MyAccount {
    pub authority: Pubkey,
    pub data: u64,
}

PDA Derivation

// On-chain
let (pda, bump) = Pubkey::find_program_address(
    &[b"seed", user.key().as_ref()],
    &program_id,
);

// In Anchor constraints
#[account(
    seeds = [b"seed", authority.key().as_ref()],
    bump,
)]
pub my_pda: Account<'info, MyData>,

CPI Pattern (Anchor 0.30+ with declare_program!)

// In idls/other_program.json (place the IDL there)
declare_program!(other_program);

// Use in your program:
use other_program::cpi;
cpi::some_instruction(ctx, args)?;
Related skills