"Build compressed PDA programs on Solana with Light System Program CPI. Create, update, close, burn, reinitialize compressed accounts. Client integration and testing."
Recursos
1Instal·la
npx skillscat add lightprotocol/skills/solana-compression Instal·la des del registre de SkillsCat.
Compressed PDA Programs
Build Solana programs with compressed accounts via manual CPI to the Light System Program. Compressed accounts cost ~100x less than regular accounts (no rent-exemption required).
When to use compressed PDAs
- Per-user state (profiles, game state, credentials)
- DePIN device registrations
- Nullifier-based double-spend prevention
- Infrequently accessed accounts
Choosing approach
| Criteria | Light-PDA (easy) | Compressed PDA (advanced) |
|---|---|---|
| When | Rent-free version of existing Anchor accounts | Custom compressed state with ZK proofs |
| Skill | light-sdk (Anchor macro pattern) |
This skill (solana-compression) |
| Macro | #[light_account(init)] |
LightAccount::new_init() manual CPI |
| Dependencies | light-sdk, light-compressible |
light-sdk, light-sdk-types |
If you just want rent-free Anchor accounts, use the light-sdk skill instead. This skill is for programs that require manual CPI to the Light System Program (custom compressed state, ZK proofs, address derivation).
Client-program interaction flow
├─ Client
│ ├─ Get ValidityProof from RPC.
│ ├─ pack accounts with PackedAccounts into PackedAddressTreeInfo and PackedStateTreeInfo.
│ ├─ pack CompressedAccountMeta.
│ ├─ Build Instruction from PackedAccounts and CompressedAccountMetas.
│ └─ Send transaction.
│
└─ Custom Program
├─ CpiAccounts parse accounts consistent with PackedAccounts.
├─ LightAccount instantiates from CompressedAccountMeta.
│
└─ Light System Program CPI
├─ Verify ValidityProof.
├─ Update State Merkle tree.
├─ Update Address Merkle tree.
└─ Complete atomic state transition.Domain references
| Topic | Reference |
|---|---|
| Program operations (create, update, close, burn, reinit) | references/compressed-pdas.md |
| Client SDK (TypeScript + Rust) | references/client.md |
| Nullifier PDAs (double-spend prevention) | references/nullifier-pdas.md |
| Error codes (6000-16034) | references/error-codes.md |
Reference repos
/home/tilo/Workspace/program-examples/
├── create-and-update/ # Basic create + update pattern
├── close-account/ # Close, burn, reinit patterns
├── token-escrow/ # Token + compressed account patterns
├── airdrop-implementations/distributor/ # Merkle + compressed
└── zk/ # ZK proof patterns
/home/tilo/Workspace/examples-zk-compression/
/home/tilo/Workspace/example-token-distribution/
/home/tilo/Workspace/example-nodejs-client/Workflow
- Clarify intent
- Recommend plan mode, if it's not activated
- Use
AskUserQuestionto resolve blind spots - All questions must be resolved before execution
- Identify references
- Match task to domain references and reference repos
- Locate relevant documentation and examples
- Write plan file (YAML task format)
- Use
AskUserQuestionfor anything unclear — never guess or assume - Identify blockers: permissions, dependencies, unknowns
- Plan must be complete before execution begins
- Use
- Execute
- Use
Tasktool with subagents for parallel research - Subagents load skills via
Skilltool - Track progress with
TodoWrite
- Use
- When stuck: spawn subagent with
Read,Glob,Grep, DeepWiki MCP access and loadskills/ask-mcp
Build and test
Required commands
Anchor programs:
anchor build
anchor testNative programs:
cargo build-sbf
cargo test-sbfForbidden shortcuts
- Do NOT use
cargo build(must usecargo build-sbf) - Do NOT use
cargo test(must usecargo test-sbf) - Do NOT skip SBF compilation
- Tests MUST run against real BPF bytecode
Failure recovery
On failure, spawn debugger agent with error context.
Loop rules:
- Each debugger gets fresh context + previous debug reports
- Each attempt tries something DIFFERENT
- NEVER GIVE UP - keep spawning until fixed
- Max 5 attempts per error
Do NOT proceed until all tests pass.
SDK references
| Package | Link |
|---|---|
light-sdk |
docs.rs |
light-client |
docs.rs |
@lightprotocol/stateless.js |
API docs |
light-program-test |
docs.rs |
DeepWiki fallback
If no matching pattern in reference repos:
mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "How to {operation}?")