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
1---2name: stacks-agent3description: AI-powered intelligence for building Stacks blockchain applications with 40 production code examples4---5
6# Stacks Agent Skill
7
8AI-powered development intelligence for building on Stacks blockchain - Bitcoin's most powerful smart contract layer.
9
10## Capabilities
11
12### Core Features
13- **Clarity Contracts**: Generate, audit, and deploy smart contracts
14- **Token Standards**: SIP-010 (fungible) and SIP-009 (NFT) templates
15- **DeFi Integration**: Alex, Velar, Bitflow, Zest, Boost, Faktory protocol patterns
16- **Security Analysis**: Vulnerability detection and best practices
17- **Stacks.js**: Frontend integration with modern @stacks/connect v7+ API
18- **BNS**: Bitcoin Name System operations
19- **Stacking**: PoX stacking and pool delegation
20- **Deployment**: Testnet and mainnet deployment guides
21
22### 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 prerequisites
25- **🚫 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 pitfalls
27- **🐛 Debugging Examples**: Real-world troubleshooting for failed transactions
28
29## Knowledge Base
30
31### Code Snippets (495+ entries)
32- **61 Clarity functions** - Complete language reference
33- **14 Contract templates** - FT, NFT, DAO, Vault, Marketplace, Stacking
34- **15 Security patterns** - Common vulnerabilities and fixes
35- **25 DeFi protocols** - Alex, Velar, Bitflow, Zest, StackingDAO, Boost, Faktory
36- **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 devnet
41
42### Production Examples (40 examples - NEW in v2.0)
43- **10 DeFi examples** - Swaps, liquidity, oracles, stacking, bonding curves, debugging
44- **10 NFT examples** - Minting, marketplace, royalties, metadata, batch operations, debugging
45- **8 Token examples** - SIP-010, vesting, allowances, burns, multi-token swaps
46- **7 Security examples** - Reentrancy, overflow, access control, rate limiting
47- **5 Auth examples** - Wallet connect, JWT, sessions, NFT gating (**No Gaia** - deprecated)
48
49### 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 domains
55
56## Workflow
57
58### Step 1: Understand Request
59Analyze user request to determine:
60- Contract type (token, NFT, DeFi, DAO, etc.)
61- Features needed (mintable, burnable, etc.)
62- Security requirements
63- Target network (testnet/mainnet)
64
65### Step 2: Search Knowledge Base
66
67**Code Snippets:**
68```bash
69python3 .shared/stacks-agent/scripts/search.py "<query>" --domain <domain>
70```
71
72**Production Examples (v2.0):**
73```bash
74python3 .shared/stacks-agent/scripts/search.py "how to swap" --examples
75python3 .shared/stacks-agent/scripts/search.py "marketplace" --domain nfts --examples
76python3 .shared/stacks-agent/scripts/search.py "token" --difficulty beginner --examples
77```
78
79**With Relationships (v2.0):**
80```bash
81python3 .shared/stacks-agent/scripts/search.py "swap tokens" --include-relationships
82```
83
84Available domains:
85- `clarity` - Clarity syntax and functions
86- `templates` - Contract templates
87- `security` - Security patterns
88- `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 snippets
93- `bns` - BNS operations
94- `stacking` - PoX stacking
95- `oracles` - Pyth Network price feeds
96- `deployment` - Deployment guides
97- `auto` - Auto-detect domain (default)
98
99### Step 3: Generate Code
100Based on search results:
1011. Select appropriate template
1022. Customize for user requirements
1033. Apply security patterns
1044. Add proper error handling
1055. Include comprehensive comments
106
107### Step 4: Security Review
108Check 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 prevention
114- Network trait compatibility
115
116### Step 5: Provide Deployment Instructions
117Include network-appropriate deployment steps from deployment.csv.
118
119## Example Usage
120
121### Example 1: Create Meme Token
122
123**User**: "Create a meme token called PEPE with 1 billion supply"
124
125**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: PEPE
130 - Symbol: PEPE
131 - Supply: 1,000,000,000
132 - Decimals: 6
1334. Apply security patterns (access control, input validation)
1345. Provide testnet deployment instructions
135
136### Example 2: NFT Collection
137
138**User**: "Build an NFT collection with royalties"
139
140**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 tracking
1444. Apply security checks
1455. Provide deployment guide
146
147### Example 3: DEX Integration
148
149**User**: "How do I swap tokens on Alex?"
150
151**Workflow**:
1521. Search: `python3 scripts/search.py "alex swap" --domain defi`
1532. Return swap-helper function signature
1543. Provide example code
1554. Include Stacks.js integration if needed
156
157### Example 4: Deploy Contract
158
159**User**: "Deploy my contract to testnet"
160
161**Workflow**:
1621. Search: `python3 scripts/search.py "testnet deploy" --domain deployment`
1632. Provide step-by-step deployment guide
1643. Include faucet link for testnet STX
1654. Explain verification process
166
167## Networks
168
169- **Mainnet**: SP... addresses, real value, production
170- **Testnet**: ST... addresses, free STX, testing only
171- **Devnet**: Local development with Clarinet
172
173## Traits and Standards
174
175### SIP-010 (Fungible Token)
176- Mainnet: `SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard`
177- Testnet: Same trait address works on testnet
178
179### SIP-009 (Non-Fungible Token)
180- Mainnet: `SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait`
181- Testnet: Same trait address works on testnet
182
183⚠️ **Important**: Always use the correct trait addresses for the target network. Using wrong trait addresses will cause deployment to fail.
184
185## Security Best Practices
186
1871. **Access Control**: Always check `tx-sender` for sensitive operations
1882. **Error Handling**: Use `try!` or `unwrap!` for all transfer operations
1893. **Input Validation**: Validate all public function parameters with `asserts!`
1904. **Arithmetic Safety**: Clarity prevents overflow/underflow automatically
1915. **Naming**: Use kebab-case for all identifiers
1926. **Error Codes**: Define as constants (e.g., `ERR-UNAUTHORIZED`)
1937. **Testing**: Test on testnet before mainnet deployment
1948. **Auditing**: Professional audit recommended for high-value contracts
195
196## Resources
197
198- Stacks Docs: https://docs.stacks.co
199- Clarity Reference: https://docs.stacks.co/clarity
200- Hiro Platform: https://platform.hiro.so
201- Explorer (Mainnet): https://explorer.hiro.so
202- Explorer (Testnet): https://explorer.hiro.so/?chain=testnet
203- Clarinet: https://github.com/hirosystems/clarinet
204- Alex DEX: https://app.alexlab.co
205- Velar DEX: https://app.velar.co
206- Bitflow DEX: https://app.bitflow.finance
207- Zest Protocol: https://www.zestprotocol.com
208
209## Important Notes
210
211- All generated contracts follow Clarity best practices
212- Security patterns are based on real-world vulnerabilities
213- Always test on testnet before mainnet deployment
214- DeFi protocol addresses are for mainnet (use testnet equivalents for testing)
215- Search functionality uses BM25 ranking for relevant results
216- Auto-domain detection works for most queries, but specifying domain is more accurate
217
218## Search Examples
219
220```bash
221# Auto-detect domain
222python3 scripts/search.py "define-public"
223
224# Search specific domain
225python3 scripts/search.py "swap tokens" --domain defi
226
227# Get more results
228python3 scripts/search.py "security vulnerability" --domain security -n 10
229
230# JSON output
231python3 scripts/search.py "stx transfer" --domain stacksjs -f json
232```
233
234## Version History
235
236- **2.0.0** (2026-01): Major update with production code and relationships
237 - ✅ 40 production code examples from live dApps
238 - ✅ 100 knowledge graph relationships
239 - ✅ Modern @stacks/connect v7+ API patterns
240 - ✅ Deprecated code removal (Gaia, openContractCall, showConnect)
241 - ✅ Security-first examples with post-conditions
242 - ✅ Debugging examples for failed transactions
243 - ✅ Pyth Network oracle integration (30 entries)
244 - ✅ Expanded to 495+ knowledge base entries
245
246- **1.0.0** (2025-01): Initial release with 170+ knowledge entries
247 - Clarity syntax and functions
248 - Contract templates
249 - Security patterns
250 - DeFi protocol integrations
251 - Stacks.js snippets
252 - BNS operations
253 - Stacking guides
254 - Deployment workflows