Rust best practices for Solana smart contract development using Anchor framework and Solana SDK
Add this skill
npx mdskills install PatrickJS/cursor-rustComprehensive Solana/Anchor ruleset with strong security, testing, and workflow guidance
Anchor framework standardslib.rs, not main.rsinitialize, update, close)utils module (e.g., account validation)declare_id!() to define program ID#[derive(Accounts)] for all instruction contexts#[account(mut)], seeds, bump])#[account] and #[derive(AnchorSerialize, AnchorDeserialize)]Init, Close, Realloc, Mut, and constraint macros to avoid manual deserializationctx.accounts to access validated context accounts#[account(zero_copy)] or #[repr(C)] for packed structuresu64, u128, or fixed-point mathtests/*.ts)anchor.workspace.MyProgram to load deployed contractsprovider.simulate() to inspect failed txsanchor test) and reset between testsprovider.connection.requestAirdrop(...)tx.confirmation.logMessagessolana_program crate when not using Anchor (bare-metal programs)AccountInfo, try_from_slice_uncheckedsolana_program::msg! for lightweight debugging logsis_signer, is_writable, key == expectedProgramError::Custom(u32) or ErrorCode enumsmsg.sender/signer with account_info.is_signerseeds, bump, and unique PDAstarget_program against expected program ID#[account(zero_copy)] and #[repr(packed)] for tight layoutsolana logs and anchor runanchor init to scaffold projectsanchor build, anchor deploy, anchor test consistentlyAnchor.toml environments for devnet/mainnet/localnetcargo fmt, lint with cargo clippyCargo.lock checked into programs/ but not root/// Rust doc comments for all instructions and accountsREADME.md with test commands and deployment stepsanchorProvider.wallet.publicKey for signer verification in testsprocess.env.ANCHOR_WALLET)cluster targets (localnet, devnet, mainnet)anchor keys sync to propagate program ID changestarget/idl/ and target/types/ to share with front endsolana-cli, anchor-cli, and node installedanchor test in CI for every PRsolana program deploy with explicit --program-id on production deploysanchor.cloud)Install via CLI
npx mdskills install PatrickJS/cursor-rustRust & Solana is a free, open-source AI agent skill. Rust best practices for Solana smart contract development using Anchor framework and Solana SDK
Install Rust & Solana with a single command:
npx mdskills install PatrickJS/cursor-rustThis downloads the skill files into your project and your AI agent picks them up automatically.
Rust & Solana works with Cursor. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.