search-aptos-examples
Skill19 starsChanged 7 months agoMITView on GitHub
This skill helps you find relevant examples in official Aptos repositories before writing new contracts. Always search examples first to follow established patterns. Repositories: - aptos-labs/aptos-core/aptos-move/move-examples/ — 53+ official Move examples demonstrating best practices - aptos-labs/daily-move/snippets/ — 17 curated educational examples covering design patterns, Move 2 features, composable NFTs, and more Categorize your contract: Priority Examples by Category: When to use: Building NFT collections, digital collectibles, tokenized assets When to use: Creating tokens, currencies, reward points When to use: Building…
In this repository8 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- analyze-gas-optimizationSkill
- deploy-contractsSkill
- generate-testsSkill
- modernize-moveSkill
- security-auditSkill
- write-contractsSkill
- create-aptos-projectSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 10 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 153
Maintain security: Keep all security checks intact
- Distinctive: line 154
Test thoroughly: Ensure 100% coverage
- Distinctive: line 252
Takeaway: Use named tokens for collections, create_object for unique items.
- Distinctive: line 273
Takeaway: Verify state conditions before executing critical operations.
- Distinctive: line 297
Takeaway: Check-effects-interactions pattern (verify, deduct, add).
- Distinctive: line 320
Before writing contract code:
- Distinctive: line 356
Keep object creation pattern
- Distinctive: line 358
Add your custom fields
- Distinctive: line 359
Add your business logic
- Distinctive: line 386
Remember: Search examples first. Understand patterns.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Search Aptos Examples Skill
Overview
This skill helps you find relevant examples in official Aptos repositories before writing new contracts. Always search examples first to follow established patterns.
Repositories:
aptos-labs/aptos-core/aptos-move/move-examples/— 53+ official Move examples demonstrating best practicesaptos-labs/daily-move/snippets/— 17 curated educational examples covering design patterns, Move 2 features, composable NFTs, and more
Core Workflow
Step 1: Identify What You're Building
Categorize your contract:
- NFTs/Tokens: NFT collections, digital assets, collectibles
- Fungible Assets: Coins, tokens, currencies
- DeFi: DEXs, AMMs, lending, staking
- Governance: DAOs, voting, proposals
- Marketplace: Trading, escrow, auctions
- Gaming: Items, characters, game logic
- Infrastructure: Registries, configs, utilities
Step 2: Search Relevant Examples
Priority Examples by Category:
NFTs & Token Objects
token_objects/- Modern object-based tokens (V2 pattern)mint_nft/- NFT minting patternsnft_dao/- NFT-gated governancecollection_manager/- Collection management- (daily-move)
composable-nfts/- NFTs that contain other NFTs - (daily-move)
modifying-nfts/- Mutable NFT metadata patterns - (daily-move)
parallel-nfts/- Concurrent NFT minting - (daily-move)
liquid-nfts/- Fractionalized/liquid NFTs
When to use: Building NFT collections, digital collectibles, tokenized assets
Fungible Assets
fungible_asset/- Modern fungible token standardcoin/- Basic coin implementationmanaged_fungible_asset/- Controlled fungible assets- (daily-move)
fa-lockup-example/- FA lockup and escrow patterns - (daily-move)
fractional-token/- Fractional token ownership - (daily-move)
controlled-mint/- Controlled minting with access control
When to use: Creating tokens, currencies, reward points
DeFi & Trading
marketplace/- NFT marketplace patternsswap/- Simple token swapliquidity_pool/- AMM pool implementationstaking/- Staking mechanisms
When to use: Building DEXs, marketplaces, trading platforms
Governance & DAOs
dao/- DAO governance patternsvoting/- Voting mechanismsmultisig/- Multi-signature accounts
When to use: Building DAOs, governance systems, voting
Basic Patterns
hello_blockchain/- Module structure basicsmessage_board/- Simple state managementresource_account/- Resource patterns (legacy - avoid for new code)- (daily-move)
error-codes/- Error code conventions and patterns - (daily-move)
private-vs-public/- Function visibility and access - (daily-move)
objects/- Object model fundamentals
When to use: Learning Move basics, simple contracts
Advanced Patterns
object_playground/- Object model explorationcapability/- Capability-based securityupgradeable/- Upgradeable contracts- (daily-move)
design-patterns/- Autonomous objects and other design patterns - (daily-move)
struct-capabilities/- Struct-based capability patterns - (daily-move)
move-2/- Move 2 language features and idioms - (daily-move)
storage/- Storage layout and optimization patterns - (daily-move)
data-structures/- Heap data structure implementation
When to use: Complex architectures, security patterns
Gaming
- (daily-move)
lootbox/- Randomized loot box mechanics
When to use: Building games, randomized rewards, loot systems
Step 3: Review Example Code
What to look for:
- Module Structure:
- How are imports organized?
- What structs are defined?
- How are error codes structured?
- Object Creation:
- How are objects created?
- Which refs are generated?
- How is ownership managed?
- Access Control:
- How is signer authority verified?
- How is object ownership checked?
- What roles/permissions exist?
- Operations:
- How are transfers handled?
- How are updates secured?
- What validations are performed?
- Testing:
- What test patterns are used?
- How is coverage achieved?
Step 4: Adapt Patterns to Your Use Case
Don't copy blindly - adapt:
- Understand the pattern: Why is it structured this way?
- Identify core concepts: What security checks are critical?
- Adapt to your needs: Modify for your specific requirements
- Maintain security: Keep all security checks intact
- Test thoroughly: Ensure 100% coverage
Example Discovery Table
| Building | Search For | Source | Key Files |
| NFT Collection | token_objects, mint_nft | aptos-core | token_objects/sources/token.move |
| Fungible Token | fungible_asset | aptos-core | fungible_asset/sources/fungible_asset.move |
| Marketplace | marketplace | aptos-core | marketplace/sources/marketplace.move |
| DAO | dao, voting | aptos-core | dao/sources/dao.move |
| Token Swap | swap, liquidity_pool | aptos-core | swap/sources/swap.move |
| Staking | staking | aptos-core | staking/sources/staking.move |
| Simple Contract | hello_blockchain, message_board | aptos-core | hello_blockchain/sources/hello.move |
| Object Patterns | object_playground | aptos-core | object_playground/sources/playground.move |
| Composable NFTs | composable-nfts | daily-move | snippets/composable-nfts/ |
| FA Lockup/Escrow | fa-lockup-example | daily-move | snippets/fa-lockup-example/ |
| Design Patterns | design-patterns | daily-move | snippets/design-patterns/ |
| Move 2 Features | move-2 | daily-move | snippets/move-2/ |
| Data Structures | data-structures | daily-move | snippets/data-structures/ |
| Storage Patterns | storage | daily-move | snippets/storage/ |
| Loot Box Patterns | lootbox | daily-move | snippets/lootbox/ |
How to Access Examples
Option 1: GitHub Web Interface
https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examplesBrowse online and read source files directly.
Option 2: Clone Repository (Recommended)
# Clone Aptos core
git clone https://github.com/aptos-labs/aptos-core.git
# Navigate to examples
cd aptos-core/aptos-move/move-examples
# List all examples
ls -la
# View specific example
cd token_objects
cat sources/token.moveOption 3: daily-move Repository
Browse online:
https://github.com/aptos-labs/daily-move/tree/main/snippetsClone locally:
git clone https://github.com/aptos-labs/daily-move.git
cd daily-move/snippets
ls -laOption 4: Search Aptos Documentation
https://aptos.dev/build/smart-contractsMany examples are documented with explanations.
Common Patterns from Examples
Pattern 1: Object Creation (from token_objects)
// From: token_objects/sources/token.move
public entry fun create_token(
creator: &signer,
collection_name: String,
description: String,
name: String,
uri: String,
) {
let constructor_ref = token::create_named_token(
creator,
collection_name,
description,
name,
option::none(),
uri,
);
// ... additional setup
}Takeaway: Use named tokens for collections, create_object for unique items.
Pattern 2: Access Control (from dao)
// From: dao/sources/dao.move
public entry fun execute_proposal(
proposer: &signer,
proposal_id: u64
) acquires DAO, Proposal {
let dao = borrow_global_mut<DAO>(@dao_addr);
let proposal = vector::borrow_mut(&mut dao.proposals, proposal_id);
// Verify proposal passed
assert!(proposal.votes_for > proposal.votes_against, E_PROPOSAL_NOT_PASSED);
// Execute actions
// ...
}Takeaway: Verify state conditions before executing critical operations.
Pattern 3: Transfer Control (from fungible_asset)
// From: fungible_asset/sources/fungible_asset.move
public fun transfer<T: key>(
from: &signer,
to: address,
amount: u64
) acquires FungibleStore {
// Verify sender has sufficient balance
let from_store = borrow_global_mut<FungibleStore<T>>(signer::address_of(from));
assert!(from_store.balance >= amount, E_INSUFFICIENT_BALANCE);
// Deduct from sender
from_store.balance = from_store.balance - amount;
// Add to recipient
let to_store = borrow_global_mut<FungibleStore<T>>(to);
to_store.balance = to_store.balance + amount;
}Takeaway: Check-effects-interactions pattern (verify, deduct, add).
ALWAYS Rules
- ✅ ALWAYS search examples before writing new contracts
- ✅ ALWAYS check both aptos-core (canonical) and daily-move (educational) repositories
- ✅ ALWAYS understand patterns before copying
- ✅ ALWAYS adapt patterns to your use case
- ✅ ALWAYS maintain security checks from examples
- ✅ ALWAYS reference which example you adapted from
- ✅ ALWAYS test adapted code thoroughly
NEVER Rules
- ❌ NEVER copy code without understanding it
- ❌ NEVER skip security checks from examples
- ❌ NEVER use deprecated patterns (resource accounts, address-based)
- ❌ NEVER assume examples are always up-to-date (verify against docs)
- ❌ NEVER mix V1 and V2 patterns
- ❌ NEVER include real private keys or credentials when adapting examples — use
"0x..."placeholders
Search Checklist
Before writing contract code:
- Identified category (NFT, DeFi, DAO, etc.)
- Found 2-3 relevant examples in aptos-core
- Checked daily-move snippets for educational examples
- Reviewed module structure
- Identified security patterns
- Understood object creation patterns
- Noted access control mechanisms
- Checked test patterns
- Ready to adapt to my use case
Example Adaptation Workflow
Step-by-Step: Building NFT Collection
- Search: Find
token_objectsexample Review Structure:
token_objects/ ├── sources/ │ ├── collection.move # Collection management │ ├── token.move # Token operations │ └── property_map.move # Metadata handling └── tests/ └── token_tests.move- Identify Key Patterns:
- Collection creation with
create_collection - Token minting with
create_named_token - Metadata storage using
PropertyMap - Transfer control with
TransferRef
- Collection creation with
- Adapt to Your Needs:
- Keep object creation pattern
- Keep security checks
- Add your custom fields
- Add your business logic
- Write comprehensive tests
- Reference in Code:
// Adapted from: aptos-core/move-examples/token_objects module my_addr::custom_nft { // ... your implementation }
References
Official Examples:
- aptos-core: https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples
- daily-move: https://github.com/aptos-labs/daily-move/tree/main/snippets
- Documentation: https://aptos.dev/build/smart-contracts
Related Skills:
write-contracts- Apply patterns after searchingsecurity-audit- Verify security of adapted codegenerate-tests- Test adapted patterns
Remember: Search examples first. Understand patterns. Adapt securely. Test thoroughly.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

