Stacks Agent Skill
AI-powered development intelligence for building on Stacks blockchain - Bitcoin's most powerful smart contract layer.
Capabilities
Core Features
- Clarity Contracts: Generate, audit, and deploy smart contracts
- Token Standards: SIP-010 (fungible) and SIP-009 (NFT) templates
- DeFi Integration: Alex, Velar, Bitflow, Zest, Boost, Faktory protocol patterns
- Security Analysis: Vulnerability detection and best practices
- Stacks.js: Frontend integration with modern @stacks/connect v7+ API
- BNS: Bitcoin Name System operations
- Stacking: PoX stacking and pool delegation
- Deployment: Testnet and mainnet deployment guides
New in v2.0 🎉
- 🎯 40 Production Code Examples: Complete working code from live dApps (sbtc-market, stacksagent, STX City)
- 🕸️ 100 Knowledge Relationships: Connected concepts showing dependencies and prerequisites
- 🚫 Zero Deprecated Code: All examples use modern API patterns (no openContractCall, showConnect, or Gaia)
- 🔒 Security-First: All examples include post-conditions, error handling, and common pitfalls
- 🐛 Debugging Examples: Real-world troubleshooting for failed transactions
Knowledge Base
Code Snippets (495+ entries)
- 61 Clarity functions - Complete language reference
- 14 Contract templates - FT, NFT, DAO, Vault, Marketplace, Stacking
- 15 Security patterns - Common vulnerabilities and fixes
- 25 DeFi protocols - Alex, Velar, Bitflow, Zest, StackingDAO, Boost, Faktory
- 76 Stacks.js snippets - Modern @stacks/connect v7+ patterns (wallet, transactions, post-conditions)
- 21 BNS operations - Name registration and resolution (Clarity + JS + API)
- 25 Stacking guides - PoX stacking and delegation (Clarity + JS + API)
- 30 Oracle integration - Pyth Network price feeds with VAA handling (Clarity + JS + API)
- 25 Deployment steps - Testnet, mainnet, and devnet
Production Examples (40 examples - NEW in v2.0)
- 10 DeFi examples - Swaps, liquidity, oracles, stacking, bonding curves, debugging
- 10 NFT examples - Minting, marketplace, royalties, metadata, batch operations, debugging
- 8 Token examples - SIP-010, vesting, allowances, burns, multi-token swaps
- 7 Security examples - Reentrancy, overflow, access control, rate limiting
- 5 Auth examples - Wallet connect, JWT, sessions, NFT gating (No Gaia - deprecated)
Knowledge Relationships (100 relationships - NEW in v2.0)
- requires - Critical dependencies (e.g., "swap requires ft-transfer")
- uses - Functional dependencies (e.g., "DEX uses post-conditions")
- javascript-for - Language bridges (e.g., "SDK implements Clarity function")
- prevents - Security defenses (e.g., "access control prevents unauthorized access")
- And 5 more relationship types connecting concepts across domains
Workflow
Step 1: Understand Request
Analyze user request to determine:
- Contract type (token, NFT, DeFi, DAO, etc.)
- Features needed (mintable, burnable, etc.)
- Security requirements
- Target network (testnet/mainnet)
Step 2: Search Knowledge Base
Code Snippets:
python3 .shared/stacks-agent/scripts/search.py "<query>" --domain <domain>
Production Examples (v2.0):
python3 .shared/stacks-agent/scripts/search.py "how to swap" --examples
python3 .shared/stacks-agent/scripts/search.py "marketplace" --domain nfts --examples
python3 .shared/stacks-agent/scripts/search.py "token" --difficulty beginner --examples
With Relationships (v2.0):
python3 .shared/stacks-agent/scripts/search.py "swap tokens" --include-relationships
Available domains:
clarity - Clarity syntax and functions
templates - Contract templates
security - Security patterns
defi - DeFi protocol integrations (swaps, liquidity, oracles)
nfts - NFT operations (minting, marketplace, royalties)
tokens - Token operations (SIP-010, vesting, allowances)
auth - Authentication (wallet connect, JWT, sessions - No Gaia)
stacksjs - Stacks.js code snippets
bns - BNS operations
stacking - PoX stacking
oracles - Pyth Network price feeds
deployment - Deployment guides
auto - Auto-detect domain (default)
Step 3: Generate Code
Based on search results:
- Select appropriate template
- Customize for user requirements
- Apply security patterns
- Add proper error handling
- Include comprehensive comments
Step 4: Security Review
Check generated code against security-patterns.csv:
- Access control (tx-sender validation)
- Arithmetic safety (overflow/underflow)
- Error handling (try! unwrap!)
- Input validation (asserts!)
- Reentrancy prevention
- Network trait compatibility
Step 5: Provide Deployment Instructions
Include network-appropriate deployment steps from deployment.csv.
Example Usage
Example 1: Create Meme Token
User: "Create a meme token called PEPE with 1 billion supply"
Workflow:
- Search templates:
python3 scripts/search.py "fungible token" --domain templates
- Search security:
python3 scripts/search.py "token security" --domain security
- Generate SIP-010 contract with:
- Name: PEPE
- Symbol: PEPE
- Supply: 1,000,000,000
- Decimals: 6
- Apply security patterns (access control, input validation)
- Provide testnet deployment instructions
Example 2: NFT Collection
User: "Build an NFT collection with royalties"
Workflow:
- Search:
python3 scripts/search.py "nft royalties" --domain templates
- Search:
python3 scripts/search.py "nft security" --domain security
- Generate SIP-009 contract with royalty tracking
- Apply security checks
- Provide deployment guide
Example 3: DEX Integration
User: "How do I swap tokens on Alex?"
Workflow:
- Search:
python3 scripts/search.py "alex swap" --domain defi
- Return swap-helper function signature
- Provide example code
- Include Stacks.js integration if needed
Example 4: Deploy Contract
User: "Deploy my contract to testnet"
Workflow:
- Search:
python3 scripts/search.py "testnet deploy" --domain deployment
- Provide step-by-step deployment guide
- Include faucet link for testnet STX
- Explain verification process
Networks
- Mainnet: SP... addresses, real value, production
- Testnet: ST... addresses, free STX, testing only
- Devnet: Local development with Clarinet
Traits and Standards
SIP-010 (Fungible Token)
- Mainnet:
SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard
- Testnet: Same trait address works on testnet
SIP-009 (Non-Fungible Token)
- Mainnet:
SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait
- Testnet: Same trait address works on testnet
⚠️ Important: Always use the correct trait addresses for the target network. Using wrong trait addresses will cause deployment to fail.
Security Best Practices
- Access Control: Always check
tx-sender for sensitive operations
- Error Handling: Use
try! or unwrap! for all transfer operations
- Input Validation: Validate all public function parameters with
asserts!
- Arithmetic Safety: Clarity prevents overflow/underflow automatically
- Naming: Use kebab-case for all identifiers
- Error Codes: Define as constants (e.g.,
ERR-UNAUTHORIZED)
- Testing: Test on testnet before mainnet deployment
- Auditing: Professional audit recommended for high-value contracts
Resources
Important Notes
- All generated contracts follow Clarity best practices
- Security patterns are based on real-world vulnerabilities
- Always test on testnet before mainnet deployment
- DeFi protocol addresses are for mainnet (use testnet equivalents for testing)
- Search functionality uses BM25 ranking for relevant results
- Auto-domain detection works for most queries, but specifying domain is more accurate
Search Examples
# Auto-detect domain
python3 scripts/search.py "define-public"
# Search specific domain
python3 scripts/search.py "swap tokens" --domain defi
# Get more results
python3 scripts/search.py "security vulnerability" --domain security -n 10
# JSON output
python3 scripts/search.py "stx transfer" --domain stacksjs -f json
Version History
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: stacks-agent3description: AI-powered intelligence for building Stacks blockchain applications with 40 production code examples Use when this capability is needed.4---56# Stacks Agent Skill78AI-powered development intelligence for building on Stacks blockchain - Bitcoin's most powerful smart contract layer.910## Capabilities1112### Core Features13- **Clarity Contracts**: Generate, audit, and deploy smart contracts14- **Token Standards**: SIP-010 (fungible) and SIP-009 (NFT) templates15- **DeFi Integration**: Alex, Velar, Bitflow, Zest, Boost, Faktory protocol patterns16- **Security Analysis**: Vulnerability detection and best practices17- **Stacks.js**: Frontend integration with modern @stacks/connect v7+ API18- **BNS**: Bitcoin Name System operations19- **Stacking**: PoX stacking and pool delegation20- **Deployment**: Testnet and mainnet deployment guides2122### New in v2.0 🎉23- **🎯 40 Production Code Examples**: Complete working code from live dApps (sbtc-market, stacksagent, STX City)24- **🕸️ 100 Knowledge Relationships**: Connected concepts showing dependencies and prerequisites25- **🚫 Zero Deprecated Code**: All examples use modern API patterns (no openContractCall, showConnect, or Gaia)26- **🔒 Security-First**: All examples include post-conditions, error handling, and common pitfalls27- **🐛 Debugging Examples**: Real-world troubleshooting for failed transactions2829## Knowledge Base3031### Code Snippets (495+ entries)32- **61 Clarity functions** - Complete language reference33- **14 Contract templates** - FT, NFT, DAO, Vault, Marketplace, Stacking34- **15 Security patterns** - Common vulnerabilities and fixes35- **25 DeFi protocols** - Alex, Velar, Bitflow, Zest, StackingDAO, Boost, Faktory36- **76 Stacks.js snippets** - Modern @stacks/connect v7+ patterns (wallet, transactions, post-conditions)37- **21 BNS operations** - Name registration and resolution (Clarity + JS + API)38- **25 Stacking guides** - PoX stacking and delegation (Clarity + JS + API)39- **30 Oracle integration** - Pyth Network price feeds with VAA handling (Clarity + JS + API)40- **25 Deployment steps** - Testnet, mainnet, and devnet4142### Production Examples (40 examples - NEW in v2.0)43- **10 DeFi examples** - Swaps, liquidity, oracles, stacking, bonding curves, debugging44- **10 NFT examples** - Minting, marketplace, royalties, metadata, batch operations, debugging45- **8 Token examples** - SIP-010, vesting, allowances, burns, multi-token swaps46- **7 Security examples** - Reentrancy, overflow, access control, rate limiting47- **5 Auth examples** - Wallet connect, JWT, sessions, NFT gating (**No Gaia** - deprecated)4849### Knowledge Relationships (100 relationships - NEW in v2.0)50- **requires** - Critical dependencies (e.g., "swap requires ft-transfer")51- **uses** - Functional dependencies (e.g., "DEX uses post-conditions")52- **javascript-for** - Language bridges (e.g., "SDK implements Clarity function")53- **prevents** - Security defenses (e.g., "access control prevents unauthorized access")54- **And 5 more relationship types** connecting concepts across domains5556## Workflow5758### Step 1: Understand Request59Analyze user request to determine:60- Contract type (token, NFT, DeFi, DAO, etc.)61- Features needed (mintable, burnable, etc.)62- Security requirements63- Target network (testnet/mainnet)6465### Step 2: Search Knowledge Base6667**Code Snippets:**68```bash69python3 .shared/stacks-agent/scripts/search.py "<query>" --domain <domain>70```7172**Production Examples (v2.0):**73```bash74python3 .shared/stacks-agent/scripts/search.py "how to swap" --examples75python3 .shared/stacks-agent/scripts/search.py "marketplace" --domain nfts --examples76python3 .shared/stacks-agent/scripts/search.py "token" --difficulty beginner --examples77```7879**With Relationships (v2.0):**80```bash81python3 .shared/stacks-agent/scripts/search.py "swap tokens" --include-relationships82```8384Available domains:85- `clarity` - Clarity syntax and functions86- `templates` - Contract templates87- `security` - Security patterns88- `defi` - DeFi protocol integrations (swaps, liquidity, oracles)89- `nfts` - NFT operations (minting, marketplace, royalties)90- `tokens` - Token operations (SIP-010, vesting, allowances)91- `auth` - Authentication (wallet connect, JWT, sessions - **No Gaia**)92- `stacksjs` - Stacks.js code snippets93- `bns` - BNS operations94- `stacking` - PoX stacking95- `oracles` - Pyth Network price feeds96- `deployment` - Deployment guides97- `auto` - Auto-detect domain (default)9899### Step 3: Generate Code100Based on search results:1011. Select appropriate template1022. Customize for user requirements1033. Apply security patterns1044. Add proper error handling1055. Include comprehensive comments106107### Step 4: Security Review108Check generated code against security-patterns.csv:109- Access control (tx-sender validation)110- Arithmetic safety (overflow/underflow)111- Error handling (try! unwrap!)112- Input validation (asserts!)113- Reentrancy prevention114- Network trait compatibility115116### Step 5: Provide Deployment Instructions117Include network-appropriate deployment steps from deployment.csv.118119## Example Usage120121### Example 1: Create Meme Token122123**User**: "Create a meme token called PEPE with 1 billion supply"124125**Workflow**:1261. Search templates: `python3 scripts/search.py "fungible token" --domain templates`1272. Search security: `python3 scripts/search.py "token security" --domain security`1283. Generate SIP-010 contract with:129 - Name: PEPE130 - Symbol: PEPE131 - Supply: 1,000,000,000132 - Decimals: 61334. Apply security patterns (access control, input validation)1345. Provide testnet deployment instructions135136### Example 2: NFT Collection137138**User**: "Build an NFT collection with royalties"139140**Workflow**:1411. Search: `python3 scripts/search.py "nft royalties" --domain templates`1422. Search: `python3 scripts/search.py "nft security" --domain security`1433. Generate SIP-009 contract with royalty tracking1444. Apply security checks1455. Provide deployment guide146147### Example 3: DEX Integration148149**User**: "How do I swap tokens on Alex?"150151**Workflow**:1521. Search: `python3 scripts/search.py "alex swap" --domain defi`1532. Return swap-helper function signature1543. Provide example code1554. Include Stacks.js integration if needed156157### Example 4: Deploy Contract158159**User**: "Deploy my contract to testnet"160161**Workflow**:1621. Search: `python3 scripts/search.py "testnet deploy" --domain deployment`1632. Provide step-by-step deployment guide1643. Include faucet link for testnet STX1654. Explain verification process166167## Networks168169- **Mainnet**: SP... addresses, real value, production170- **Testnet**: ST... addresses, free STX, testing only171- **Devnet**: Local development with Clarinet172173## Traits and Standards174175### SIP-010 (Fungible Token)176- Mainnet: `SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard`177- Testnet: Same trait address works on testnet178179### SIP-009 (Non-Fungible Token)180- Mainnet: `SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait`181- Testnet: Same trait address works on testnet182183⚠️ **Important**: Always use the correct trait addresses for the target network. Using wrong trait addresses will cause deployment to fail.184185## Security Best Practices1861871. **Access Control**: Always check `tx-sender` for sensitive operations1882. **Error Handling**: Use `try!` or `unwrap!` for all transfer operations1893. **Input Validation**: Validate all public function parameters with `asserts!`1904. **Arithmetic Safety**: Clarity prevents overflow/underflow automatically1915. **Naming**: Use kebab-case for all identifiers1926. **Error Codes**: Define as constants (e.g., `ERR-UNAUTHORIZED`)1937. **Testing**: Test on testnet before mainnet deployment1948. **Auditing**: Professional audit recommended for high-value contracts195196## Resources197198- Stacks Docs: https://docs.stacks.co199- Clarity Reference: https://docs.stacks.co/clarity200- Hiro Platform: https://platform.hiro.so201- Explorer (Mainnet): https://explorer.hiro.so202- Explorer (Testnet): https://explorer.hiro.so/?chain=testnet203- Clarinet: https://github.com/hirosystems/clarinet204- Alex DEX: https://app.alexlab.co205- Velar DEX: https://app.velar.co206- Bitflow DEX: https://app.bitflow.finance207- Zest Protocol: https://www.zestprotocol.com208209## Important Notes210211- All generated contracts follow Clarity best practices212- Security patterns are based on real-world vulnerabilities213- Always test on testnet before mainnet deployment214- DeFi protocol addresses are for mainnet (use testnet equivalents for testing)215- Search functionality uses BM25 ranking for relevant results216- Auto-domain detection works for most queries, but specifying domain is more accurate217218## Search Examples219220```bash221# Auto-detect domain222python3 scripts/search.py "define-public"223224# Search specific domain225python3 scripts/search.py "swap tokens" --domain defi226227# Get more results228python3 scripts/search.py "security vulnerability" --domain security -n 10229230# JSON output231python3 scripts/search.py "stx transfer" --domain stacksjs -f json232```233234## Version History235236- **2.0.0** (2026-01): Major update with production code and relationships237 - ✅ 40 production code examples from live dApps238 - ✅ 100 knowledge graph relationships239 - ✅ Modern @stacks/connect v7+ API patterns240 - ✅ Deprecated code removal (Gaia, openContractCall, showConnect)241 - ✅ Security-first examples with post-conditions242 - ✅ Debugging examples for failed transactions243 - ✅ Pyth Network oracle integration (30 entries)244 - ✅ Expanded to 495+ knowledge base entries245246- **1.0.0** (2025-01): Initial release with 170+ knowledge entries247 - Clarity syntax and functions248 - Contract templates249 - Security patterns250 - DeFi protocol integrations251 - Stacks.js snippets252 - BNS operations253 - Stacking guides254 - Deployment workflows255256---257> Converted and distributed by [TomeVault](https://tomevault.io/claim/kai-builder) — claim your Tome and manage your conversions.258<!-- tomevault:4.0:skill_md:2026-04-11 -->