Skip to main content
ClaudeWave
Slash Command97 repo starsupdated 1mo ago

write-docs

The write-docs command generates comprehensive documentation for Solana blockchain code, including programs, APIs, and components. Use it to create instruction documentation with account tables and error codes, SDK function references with parameters and examples, component property guides, or README files with setup instructions and deployment information. It identifies the documentation type and applies appropriate templates and best practices for clarity and completeness.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/solanabr/solana-ai-kit/HEAD/.claude/commands/write-docs.md -o ~/.claude/commands/write-docs.md
Then start a new Claude Code session; the slash command loads automatically.

write-docs.md

Generate comprehensive documentation for Solana blockchain code.

## Code to Document

$ARGUMENTS

## Related Context

- **Solana Programs**: See [programs/anchor.md](../skills/ext/solana-dev/skill/references/programs/anchor.md) for IDL patterns
- **Unity/C#**: See [solana-game SKILL.md](../skills/ext/solana-game/skill/SKILL.md) for Unity/C# patterns
- **Detailed Templates**: See **tech-docs-writer** agent for full templates

## Documentation Strategy

### 1. Identify Documentation Type

| Type | What to Generate |
|------|------------------|
| **Program** | Instructions, accounts, PDAs, errors, security, CU |
| **SDK/API** | Functions, params, returns, errors, examples |
| **Component** | Props/properties, events, usage patterns |
| **README** | Overview, setup, quick start, deployment |

### 2. Documentation Requirements

**For Instructions/Endpoints:**
- Accounts table (name, type, description)
- Arguments table (name, type, validation)
- Error codes with descriptions
- Access control notes
- Compute units estimate
- Working code example

**For Account Structures:**
- Purpose and lifecycle
- Size calculation (include discriminator)
- Field table with types and offsets
- PDA seeds (if applicable)
- Rent cost

**For README:**
- Program IDs (mainnet/devnet)
- Installation command
- Quick start example
- Instruction summary table
- Security/audit status

### 3. Best Practices

**Do:**
- Document ALL public functions/instructions
- Include working code examples
- Explain "why", not just "what"
- Include error scenarios
- Update docs when code changes

**Don't:**
- Document obvious code
- Leave non-compiling examples
- Skip security considerations
- Forget to document errors

## Output

Generate documentation appropriate to the code type:

1. **Programs**: Instruction docs, account docs, error codes
2. **SDKs**: Function docs, type definitions, examples
3. **Components**: Props, events, usage patterns
4. **Projects**: README with setup and deployment

For complex projects, delegate to **tech-docs-writer** agent.
anchor-engineerSubagent

Anchor framework specialist for rapid Solana program development. Use for building programs with Anchor macros, IDL generation, account validation, and standardized patterns. Prioritizes developer experience while maintaining security.\\n\\nUse when: Building new programs quickly, team projects needing standardization, projects requiring IDL for client generation, or when developer experience is prioritized over maximum CU optimization.

defi-engineerSubagent

DeFi integration specialist for composing with Solana protocols including Jupiter, Drift, Kamino, Raydium, Orca, Meteora, Marginfi, and Sanctum. Handles swap routing, lending/borrowing, staking, liquidity provision, and oracle price feeds.\n\nUse when: Integrating DeFi protocols, building swap interfaces, implementing lending/borrowing, setting up yield strategies, working with Pyth/Switchboard oracles, or composing multi-protocol transactions.

devops-engineerSubagent

CI/CD, infrastructure, and deployment specialist for Solana projects. Handles GitHub Actions, Docker, monitoring, RPC management, and Cloudflare Workers edge deployment.\n\nUse when: Setting up CI/CD pipelines, containerizing Solana validators or programs, configuring monitoring and alerting, managing RPC infrastructure, deploying edge workers, or automating build and deploy workflows.

game-architectSubagent

Senior Solana game architect for game system design, Unity/C# architecture, on-chain game state, player progression, NFT integration, and PlaySolana ecosystem. Use for high-level game design decisions, architecture reviews, and planning complex game systems.\n\nUse when: Designing new Solana games from scratch, planning game state on-chain, Unity project architecture, integrating with PlaySolana/PSG1, or deciding between implementation approaches.

mobile-engineerSubagent

React Native and Expo specialist for building Solana mobile dApps. Handles mobile wallet adapter integration, transaction signing UX, deep linking, and mobile-specific performance optimization.\n\nUse when: Building React Native or Expo mobile apps with Solana integration, implementing mobile wallet adapter flows, setting up deep links for transaction signing, or optimizing mobile dApp performance.

pinocchio-engineerSubagent

CU optimization specialist using Pinocchio framework. Use for performance-critical programs requiring 80-95% CU reduction vs Anchor. Specializes in zero-copy access, manual validation, and minimal binary size.\\n\\nUse when: CU limits are being hit, transaction costs are significant at scale, binary size must be minimized, or maximum throughput is required.

rust-backend-engineerSubagent

Rust backend specialist for building async services that interact with Solana blockchain. Builds APIs, indexing services, and off-chain processing using Axum, Tokio, and modern async patterns.\n\nUse when: Building REST/WebSocket APIs for Solana dApps, implementing transaction indexers, creating webhook services, or any Rust backend that interacts with Solana.

solana-architectSubagent

Senior Solana program architect for system design, account structures, PDA schemes, token economics, and cross-program composability. Use for high-level design decisions, architecture reviews, and planning complex multi-program systems.\n\nUse when: Designing new programs from scratch, planning account structures, optimizing PDA schemes, reviewing architecture for security, or deciding between implementation approaches.