/SKILL.md
Use this skill whenever the user wants to write, scaffold, or build a Solana smart contract or program from scratch. Triggers on: "write a Solana program", "create a smart contract", "build an anchor program", "write a native Rust Solana program", "scaffold a Solana program", "help me write a program that does X on Solana", or any request to produce production-grade on-chain Solana code. This skill enforces Frank Castle's security best practices and pitfall avoidance guidelines automatically — giving every program a first layer of protection before it ever reaches an auditor. Always use this skill — even for simple programs — whenever Solana program code is the primary deliverable.
npx skillsauth add neromerob/safe-solana-builder safe-solana-builderInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are writing production-grade Solana programs. Security is not an afterthought — it is baked into every line. Every program produced by this skill ships with a full project scaffold, a test file skeleton, and a security checklist.
This skill systematically addresses the following vulnerability classes derived from real Solana protocol audits:
If the user has not already specified, ask exactly this (and nothing else):
"Should I write this in Native Rust, Anchor, or Pinocchio?"
Pinocchio is Anza's zero-dependency, zero-copy framework — 88–95% CU reduction vs. Anchor. Best for high-throughput programs (DEXs, orderbooks, vaults). It is unaudited — flag this in the checklist for Critical programs.
Wait for the answer before proceeding.
Once the framework is chosen, read the following files before writing a single line of code:
Always read first (both files):
references/shared-base.md — Core security rules, pitfall patterns, and best practices for ALL Solana programs. Sections 1–10 cover foundational security; sections 11–20 cover vulnerability-derived rules from real protocol audits.Then read the framework-specific file:
references/native-rust.mdreferences/anchor.mdreferences/pinocchio.md
→ Framework-specific patterns, constraints, additional pitfalls, and common build/tooling errors.Check for a relevant example:
See the Examples table at the bottom of this file. If a similar program exists in examples/, read it before writing — use it as a quality and structure benchmark.
Do not skip or skim these files. They are the source of truth for this skill.
Before gathering requirements, classify the program's sensitivity. This determines how thorough your security comments and "Known Limitations" section must be.
| Level | Criteria | Examples | |---|---|---| | 🟢 Low | No SOL/token custody, no CPI, single user, read-heavy | Counter, registry, simple config | | 🟡 Medium | Token transfers, basic CPI, multi-user state, PDAs | Staking, voting, simple escrow | | 🔴 Critical | Vaults, multi-CPI chains, admin keys, large TVL potential | AMM, lending, NFT launchpad, bridges |
State the risk level explicitly at the top of your security checklist. For 🔴 Critical programs: add a "High-Risk Decisions" section to the checklist and flag every admin key, upgrade authority, and irreversible state transition.
Collect the following in one message (if not already provided):
If the user's description already covers most of these, proceed and note your assumptions clearly.
Before writing, run through shared-base.md and the framework file. Flag which rules apply to this program's design. Note any inherent risks in the design itself.
Deliver a complete, ready-to-build project structure. Not just lib.rs — the full scaffold:
For Anchor:
<program-name>/
├── Anchor.toml
├── Cargo.toml
├── programs/
│ └── <program-name>/
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
└── tests/
└── <program-name>.ts
For Native Rust:
<program-name>/
├── Cargo.toml
└── src/
├── lib.rs
├── instruction.rs
├── processor.rs
├── state.rs
└── error.rs
Requirements:
Always produce a test file. For Anchor: TypeScript using @coral-xyz/anchor. For Native Rust: Rust integration tests using solana-program-test.
The test file must cover:
Happy path tests (implement these fully):
Security/edge case tests (scaffold with TODO bodies but correct structure):
Mark each TODO test with a comment explaining what it should verify and why it matters.
Produce security-checklist.md with this structure:
# Security Checklist — <ProgramName>
## Risk Level
🟢 Low | 🟡 Medium | 🔴 Critical — <one sentence justification>
## High-Risk Decisions (🔴 Critical only)
- <Every admin key, upgrade authority, irreversible state transition — with mitigation notes>
## Rules Applied
| # | Category | Rule | Status | Notes |
|---|----------|------|--------|-------|
...
## Assumptions Made
- <List assumptions about accounts, roles, business logic>
## Known Limitations / Follow-up for Auditor
- <Anything that needs manual review, known tradeoffs, recommended extensions>
---
*Generated using Frank Castle's Safe Solana Builder*
Present files in this order:
lib.rs (and additional source files for native)security-checklist.mdEnd with:
"This program was written following Frank Castle's Safe Solana Builder guidelines. The checklist above shows every security rule applied. The test file includes a scaffold for security edge cases — fill in the TODOs before mainnet. Recommend a full audit before deployment."
The examples/ directory contains complete reference programs written to this skill's standard. Before writing, check if a similar example exists — use it to calibrate output quality, structure, and checklist depth. Do not copy-paste; treat it as a quality benchmark.
| Example | Framework | Risk Level | What it demonstrates |
|---|---|---|---|
| examples/nft-whitelist-mint/ | Anchor | 🔴 Critical | MintConfig PDA, per-user WhitelistEntry PDA, double-mint guard, Metaplex CPI with program ID verification, SOL balance check around CPI, Token-2022 compatible mint, safe account close |
Each example folder contains:
lib.rs — the full programsecurity-checklist.md — the applied rules checklistremaining_accounts: Apply the same ownership, signer, and type checks as named accounts. Flag in checklist.development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.
development
End-to-end Parallels smoke, upgrade, and rerun workflow for OpenClaw across macOS, Windows, and Linux guests. Use when Codex needs to run, rerun, debug, or interpret VM-based install, onboarding, gateway smoke tests, latest-release-to-main upgrade checks, fresh snapshot retests, or optional Discord roundtrip verification under Parallels.