From d9091f3793dea9053b39c68e7538650f63f1d2fc Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sat, 29 Nov 2025 18:53:14 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 15 ++ README.md | 3 + commands/optimize-gas.md | 179 ++++++++++++++++++ plugin.lock.json | 85 +++++++++ skills/skill-adapter/assets/README.md | 7 + .../skill-adapter/assets/config-template.json | 32 ++++ skills/skill-adapter/assets/skill-schema.json | 28 +++ skills/skill-adapter/assets/test-data.json | 27 +++ skills/skill-adapter/references/README.md | 8 + .../references/best-practices.md | 69 +++++++ skills/skill-adapter/references/examples.md | 70 +++++++ skills/skill-adapter/scripts/README.md | 8 + .../skill-adapter/scripts/helper-template.sh | 42 ++++ skills/skill-adapter/scripts/validation.sh | 32 ++++ 14 files changed, 605 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/optimize-gas.md create mode 100644 plugin.lock.json create mode 100644 skills/skill-adapter/assets/README.md create mode 100644 skills/skill-adapter/assets/config-template.json create mode 100644 skills/skill-adapter/assets/skill-schema.json create mode 100644 skills/skill-adapter/assets/test-data.json create mode 100644 skills/skill-adapter/references/README.md create mode 100644 skills/skill-adapter/references/best-practices.md create mode 100644 skills/skill-adapter/references/examples.md create mode 100644 skills/skill-adapter/scripts/README.md create mode 100755 skills/skill-adapter/scripts/helper-template.sh create mode 100755 skills/skill-adapter/scripts/validation.sh diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..e3ec619 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "gas-fee-optimizer", + "description": "Optimize transaction gas fees with timing and routing recommendations", + "version": "1.0.0", + "author": { + "name": "Claude Code Plugins", + "email": "[email protected]" + }, + "skills": [ + "./skills" + ], + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9bde74a --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# gas-fee-optimizer + +Optimize transaction gas fees with timing and routing recommendations diff --git a/commands/optimize-gas.md b/commands/optimize-gas.md new file mode 100644 index 0000000..5c8c730 --- /dev/null +++ b/commands/optimize-gas.md @@ -0,0 +1,179 @@ +--- +description: Optimize gas fees with timing and routing strategies +shortcut: gas +--- + +# Gas Fee Optimizer + +You are a gas fee optimization specialist. When this command is invoked, help users minimize transaction costs through strategic timing, routing, and alternative solutions. + +## Your Task + +Analyze gas fees and provide optimization strategies: + +1. **Current Gas Analysis**: + - Current base fee (gwei) + - Priority fee recommendations + - Max fee calculations + - Total transaction cost estimate + +2. **Historical Context**: + - Compare to 24h average + - Compare to 7-day average + - Identify typical low-fee periods + - Current network congestion level + +3. **Timing Optimization**: + - Best time windows for transactions + - Expected gas price patterns + - Congestion forecasts + - Urgency vs savings trade-off + +4. **Alternative Solutions**: + - Layer 2 options (Arbitrum, Optimism, Base, zkSync) + - Sidechains (Polygon, Gnosis Chain) + - Batch transaction opportunities + - Alternative routes with cost comparison + +5. **Smart Contract Optimization** (if applicable): + - Gas-efficient alternatives + - Batching strategies + - Contract interaction tips + - Approval optimization + +## Output Format + +Present analysis in this structure: + +```markdown +## Gas Fee Optimization Report + +### Current Network Status +- **Base Fee**: [X] gwei +- **Priority Fee**: [Y] gwei (recommended) +- **Max Fee**: [Z] gwei +- **Network Status**: [Low/Medium/High/Extreme] Congestion + +**Estimated Transaction Cost:** +- Simple Transfer: ~$[X] ([Y] gwei × 21,000 gas) +- Token Swap: ~$[A] ([B] gwei × 150,000 gas) +- NFT Mint: ~$[C] ([D] gwei × 200,000 gas) + +### Historical Comparison +| Metric | Current | 24h Avg | 7d Avg | Percentile | +|--------|---------|---------|--------|------------| +| Base Fee | [X] gwei | [Y] gwei | [Z] gwei | [P]th | + + **Assessment**: [Well above/Above/Near/Below] average + +### Timing Recommendations + +**Best Time Windows (UTC):** +1. ⏰ [Time Range]: Typically [X]% lower ([Y] gwei avg) +2. ⏰ [Time Range]: Typically [A]% lower ([B] gwei avg) +3. ⏰ [Time Range]: Typically [C]% lower ([D] gwei avg) + +**Current Recommendation:** +- **Urgent**: Pay ~[X] gwei now (~$[Y] for typical tx) +- ⏳ **Can wait 1-2h**: Expected [A]% savings (~$[B]) +- **Can wait 6-12h**: Expected [C]% savings (~$[D]) +- **Not urgent**: Wait for next low period ([Day/Time]) + +### Alternative Routes + +**Layer 2 Solutions:** +| Network | Current Gas | Tx Cost | Time | Liquidity | +|---------|-------------|---------|------|-----------| +| Arbitrum | [X] gwei | ~$[Y] | ~15 min | High | +| Optimism | [A] gwei | ~$[B] | ~15 min | High | +| Base | [C] gwei | ~$[D] | ~2 min | Medium | +| zkSync | [E] gwei | ~$[F] | ~10 min | Medium | + +**Sidechain Options:** +| Network | Tx Cost | Bridge Fee | Total | Best For | +|---------|---------|------------|-------|----------| +| Polygon | ~$[X] | ~$[Y] | ~$[Z] | [Use case] | +| Gnosis | ~$[A] | ~$[B] | ~$[C] | [Use case] | + +### Optimization Strategies + +**For Your Transaction:** +1. **[Strategy 1]**: [Description] → Save ~$[X] +2. **[Strategy 2]**: [Description] → Save ~$[Y] +3. **[Strategy 3]**: [Description] → Save ~$[Z] + +### Cost-Benefit Analysis + +**If you wait [X] hours:** +- Expected savings: $[Y] ([Z]%) +- Risk: Gas may increase by [A]% +- Recommendation: [Wait/Execute now] + +### Quick Tips +- Set max fee to [X] gwei for [confidence]% chance of inclusion +- Use [Wallet] for better gas estimates +- Enable EIP-1559 for automatic pricing +- Consider batching multiple transactions +``` + +## Gas Calculation Formulas + +### EIP-1559 (Current Ethereum) +``` +Max Fee = Base Fee + Priority Fee +Total Cost = (Base Fee + Priority Fee) × Gas Units +``` + +### Typical Gas Limits +- ETH transfer: 21,000 gas +- ERC-20 transfer: ~65,000 gas +- Token swap: ~150,000 gas +- NFT mint: ~200,000 gas +- Complex DeFi: ~300,000+ gas + +## Data to Reference + +When providing recommendations, check: +- **Etherscan Gas Tracker**: Current gas prices +- **ETH Gas Station**: Historical patterns +- **Blocknative**: Real-time mempool +- **L2Fees.info**: Layer 2 comparison +- **Gas Now**: Timing predictions + +## Example Queries + +Users might ask: +- "What's the current gas price?" +- "Should I mint this NFT now or wait?" +- "Compare gas costs: Ethereum vs Arbitrum" +- "When is the best time to make a swap?" +- "How can I reduce gas fees for token approvals?" + +## Important Considerations + +### Transaction Urgency +- **Time-sensitive** (arbitrage, auctions): Pay premium +- **Routine** (transfers, swaps): Wait for optimal times +- **Non-urgent** (portfolio rebalancing): Be patient + +### Risk Factors +- Gas prices can spike unexpectedly +- Waiting too long may miss opportunities +- L2 bridges have their own costs +- Consider total journey, not just one leg + +## When to Recommend L2s + +Suggest Layer 2 when: +- User makes frequent transactions +- Total value justifies bridge costs +- Supported protocols exist on L2 +- User is comfortable with bridge risk + +## Notes to Emphasize + +- Gas prices are highly volatile +- Historical patterns don't guarantee future prices +- Consider opportunity cost of waiting +- Factor in urgency and transaction value +- Bridge costs can negate L2 savings for one-off transactions diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..5162918 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,85 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/crypto/gas-fee-optimizer", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "c2c445c91feb172080d875758f1280db5a5fcf31", + "treeHash": "d359d967de8a6d83f90d8827f2fc33c8620e07ffb8b35815236fb2a908cf6a6f", + "generatedAt": "2025-11-28T10:18:28.331982Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "gas-fee-optimizer", + "description": "Optimize transaction gas fees with timing and routing recommendations", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "387a1cac67a8a931169c7b31cf1e418315865cbad6ecfa544098d78038e5e555" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "e7007a8308a2dfb66e91480423310e6f209772254acd4684da14e779178c3a64" + }, + { + "path": "commands/optimize-gas.md", + "sha256": "0237bc2d66e6ae3adc24903a8fb5e56d98aa9def476aaf8c50618ded2a0af0bc" + }, + { + "path": "skills/skill-adapter/references/examples.md", + "sha256": "922bbc3c4ebf38b76f515b5c1998ebde6bf902233e00e2c5a0e9176f975a7572" + }, + { + "path": "skills/skill-adapter/references/best-practices.md", + "sha256": "c8f32b3566252f50daacd346d7045a1060c718ef5cfb07c55a0f2dec5f1fb39e" + }, + { + "path": "skills/skill-adapter/references/README.md", + "sha256": "b97cf8280353ae2238675efd5f3a3e516cff1100261006def88e7dd53242f603" + }, + { + "path": "skills/skill-adapter/scripts/helper-template.sh", + "sha256": "0881d5660a8a7045550d09ae0acc15642c24b70de6f08808120f47f86ccdf077" + }, + { + "path": "skills/skill-adapter/scripts/validation.sh", + "sha256": "92551a29a7f512d2036e4f1fb46c2a3dc6bff0f7dde4a9f699533e446db48502" + }, + { + "path": "skills/skill-adapter/scripts/README.md", + "sha256": "fbf7c8b61fa51e241aa72dd51a5dafd9e9bd82c0a375b85857c34e503dbd18bc" + }, + { + "path": "skills/skill-adapter/assets/test-data.json", + "sha256": "ac17dca3d6e253a5f39f2a2f1b388e5146043756b05d9ce7ac53a0042eee139d" + }, + { + "path": "skills/skill-adapter/assets/README.md", + "sha256": "60f0f18a080e9de5b07f991c3aa0932a1b20581849ec49f958bda5985a4e4dbe" + }, + { + "path": "skills/skill-adapter/assets/skill-schema.json", + "sha256": "f5639ba823a24c9ac4fb21444c0717b7aefde1a4993682897f5bf544f863c2cd" + }, + { + "path": "skills/skill-adapter/assets/config-template.json", + "sha256": "0c2ba33d2d3c5ccb266c0848fc43caa68a2aa6a80ff315d4b378352711f83e1c" + } + ], + "dirSha256": "d359d967de8a6d83f90d8827f2fc33c8620e07ffb8b35815236fb2a908cf6a6f" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/skill-adapter/assets/README.md b/skills/skill-adapter/assets/README.md new file mode 100644 index 0000000..5ec2649 --- /dev/null +++ b/skills/skill-adapter/assets/README.md @@ -0,0 +1,7 @@ +# Assets + +Bundled resources for gas-fee-optimizer skill + +- [ ] gas_price_chart_template.html: HTML template for displaying gas price charts +- [ ] l2_comparison_table_template.html: HTML template for displaying a table comparing gas costs across different Layer 2 solutions +- [ ] example_gas_price_data.json: Example JSON file containing gas price data diff --git a/skills/skill-adapter/assets/config-template.json b/skills/skill-adapter/assets/config-template.json new file mode 100644 index 0000000..16f1712 --- /dev/null +++ b/skills/skill-adapter/assets/config-template.json @@ -0,0 +1,32 @@ +{ + "skill": { + "name": "skill-name", + "version": "1.0.0", + "enabled": true, + "settings": { + "verbose": false, + "autoActivate": true, + "toolRestrictions": true + } + }, + "triggers": { + "keywords": [ + "example-trigger-1", + "example-trigger-2" + ], + "patterns": [] + }, + "tools": { + "allowed": [ + "Read", + "Grep", + "Bash" + ], + "restricted": [] + }, + "metadata": { + "author": "Plugin Author", + "category": "general", + "tags": [] + } +} diff --git a/skills/skill-adapter/assets/skill-schema.json b/skills/skill-adapter/assets/skill-schema.json new file mode 100644 index 0000000..8dc154c --- /dev/null +++ b/skills/skill-adapter/assets/skill-schema.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Claude Skill Configuration", + "type": "object", + "required": ["name", "description"], + "properties": { + "name": { + "type": "string", + "pattern": "^[a-z0-9-]+$", + "maxLength": 64, + "description": "Skill identifier (lowercase, hyphens only)" + }, + "description": { + "type": "string", + "maxLength": 1024, + "description": "What the skill does and when to use it" + }, + "allowed-tools": { + "type": "string", + "description": "Comma-separated list of allowed tools" + }, + "version": { + "type": "string", + "pattern": "^\\d+\\.\\d+\\.\\d+$", + "description": "Semantic version (x.y.z)" + } + } +} diff --git a/skills/skill-adapter/assets/test-data.json b/skills/skill-adapter/assets/test-data.json new file mode 100644 index 0000000..f0cd871 --- /dev/null +++ b/skills/skill-adapter/assets/test-data.json @@ -0,0 +1,27 @@ +{ + "testCases": [ + { + "name": "Basic activation test", + "input": "trigger phrase example", + "expected": { + "activated": true, + "toolsUsed": ["Read", "Grep"], + "success": true + } + }, + { + "name": "Complex workflow test", + "input": "multi-step trigger example", + "expected": { + "activated": true, + "steps": 3, + "toolsUsed": ["Read", "Write", "Bash"], + "success": true + } + } + ], + "fixtures": { + "sampleInput": "example data", + "expectedOutput": "processed result" + } +} diff --git a/skills/skill-adapter/references/README.md b/skills/skill-adapter/references/README.md new file mode 100644 index 0000000..a910dd8 --- /dev/null +++ b/skills/skill-adapter/references/README.md @@ -0,0 +1,8 @@ +# References + +Bundled resources for gas-fee-optimizer skill + +- [ ] ethereum_gas_mechanics.md: Detailed explanation of Ethereum gas mechanics, including base fee, priority fee, and gas limits +- [ ] l2_scaling_solutions.md: Overview of different Layer 2 scaling solutions and their gas cost characteristics +- [ ] gas_optimization_strategies.md: Collection of gas optimization strategies for different transaction types +- [ ] etherscan_api_documentation.md: Documentation for the Etherscan API, which can be used to fetch gas price data diff --git a/skills/skill-adapter/references/best-practices.md b/skills/skill-adapter/references/best-practices.md new file mode 100644 index 0000000..3505048 --- /dev/null +++ b/skills/skill-adapter/references/best-practices.md @@ -0,0 +1,69 @@ +# Skill Best Practices + +Guidelines for optimal skill usage and development. + +## For Users + +### Activation Best Practices + +1. **Use Clear Trigger Phrases** + - Match phrases from skill description + - Be specific about intent + - Provide necessary context + +2. **Provide Sufficient Context** + - Include relevant file paths + - Specify scope of analysis + - Mention any constraints + +3. **Understand Tool Permissions** + - Check allowed-tools in frontmatter + - Know what the skill can/cannot do + - Request appropriate actions + +### Workflow Optimization + +- Start with simple requests +- Build up to complex workflows +- Verify each step before proceeding +- Use skill consistently for related tasks + +## For Developers + +### Skill Development Guidelines + +1. **Clear Descriptions** + - Include explicit trigger phrases + - Document all capabilities + - Specify limitations + +2. **Proper Tool Permissions** + - Use minimal necessary tools + - Document security implications + - Test with restricted tools + +3. **Comprehensive Documentation** + - Provide usage examples + - Document common pitfalls + - Include troubleshooting guide + +### Maintenance + +- Keep version updated +- Test after tool updates +- Monitor user feedback +- Iterate on descriptions + +## Performance Tips + +- Scope skills to specific domains +- Avoid overlapping trigger phrases +- Keep descriptions under 1024 chars +- Test activation reliability + +## Security Considerations + +- Never include secrets in skill files +- Validate all inputs +- Use read-only tools when possible +- Document security requirements diff --git a/skills/skill-adapter/references/examples.md b/skills/skill-adapter/references/examples.md new file mode 100644 index 0000000..b1d8bd2 --- /dev/null +++ b/skills/skill-adapter/references/examples.md @@ -0,0 +1,70 @@ +# Skill Usage Examples + +This document provides practical examples of how to use this skill effectively. + +## Basic Usage + +### Example 1: Simple Activation + +**User Request:** +``` +[Describe trigger phrase here] +``` + +**Skill Response:** +1. Analyzes the request +2. Performs the required action +3. Returns results + +### Example 2: Complex Workflow + +**User Request:** +``` +[Describe complex scenario] +``` + +**Workflow:** +1. Step 1: Initial analysis +2. Step 2: Data processing +3. Step 3: Result generation +4. Step 4: Validation + +## Advanced Patterns + +### Pattern 1: Chaining Operations + +Combine this skill with other tools: +``` +Step 1: Use this skill for [purpose] +Step 2: Chain with [other tool] +Step 3: Finalize with [action] +``` + +### Pattern 2: Error Handling + +If issues occur: +- Check trigger phrase matches +- Verify context is available +- Review allowed-tools permissions + +## Tips & Best Practices + +- ✅ Be specific with trigger phrases +- ✅ Provide necessary context +- ✅ Check tool permissions match needs +- ❌ Avoid vague requests +- ❌ Don't mix unrelated tasks + +## Common Issues + +**Issue:** Skill doesn't activate +**Solution:** Use exact trigger phrases from description + +**Issue:** Unexpected results +**Solution:** Check input format and context + +## See Also + +- Main SKILL.md for full documentation +- scripts/ for automation helpers +- assets/ for configuration examples diff --git a/skills/skill-adapter/scripts/README.md b/skills/skill-adapter/scripts/README.md new file mode 100644 index 0000000..e71b8fa --- /dev/null +++ b/skills/skill-adapter/scripts/README.md @@ -0,0 +1,8 @@ +# Scripts + +Bundled resources for gas-fee-optimizer skill + +- [ ] gas_price_checker.py: Script to fetch current gas prices from various sources (Etherscan, etc.) +- [ ] historical_gas_analysis.py: Script to analyze historical gas price data and identify optimal transaction times +- [ ] l2_gas_comparison.py: Script to compare gas costs across different Layer 2 solutions (Arbitrum, Optimism, Polygon, etc.) +- [ ] transaction_cost_estimator.py: Script to estimate the gas cost for specific transaction types (ETH transfer, token swap, etc.) diff --git a/skills/skill-adapter/scripts/helper-template.sh b/skills/skill-adapter/scripts/helper-template.sh new file mode 100755 index 0000000..c4aae90 --- /dev/null +++ b/skills/skill-adapter/scripts/helper-template.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Helper script template for skill automation +# Customize this for your skill's specific needs + +set -e + +function show_usage() { + echo "Usage: $0 [options]" + echo "" + echo "Options:" + echo " -h, --help Show this help message" + echo " -v, --verbose Enable verbose output" + echo "" +} + +# Parse arguments +VERBOSE=false + +while [[ $# -gt 0 ]]; do + case $1 in + -h|--help) + show_usage + exit 0 + ;; + -v|--verbose) + VERBOSE=true + shift + ;; + *) + echo "Unknown option: $1" + show_usage + exit 1 + ;; + esac +done + +# Your skill logic here +if [ "$VERBOSE" = true ]; then + echo "Running skill automation..." +fi + +echo "✅ Complete" diff --git a/skills/skill-adapter/scripts/validation.sh b/skills/skill-adapter/scripts/validation.sh new file mode 100755 index 0000000..590af58 --- /dev/null +++ b/skills/skill-adapter/scripts/validation.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Skill validation helper +# Validates skill activation and functionality + +set -e + +echo "🔍 Validating skill..." + +# Check if SKILL.md exists +if [ ! -f "../SKILL.md" ]; then + echo "❌ Error: SKILL.md not found" + exit 1 +fi + +# Validate frontmatter +if ! grep -q "^---$" "../SKILL.md"; then + echo "❌ Error: No frontmatter found" + exit 1 +fi + +# Check required fields +if ! grep -q "^name:" "../SKILL.md"; then + echo "❌ Error: Missing 'name' field" + exit 1 +fi + +if ! grep -q "^description:" "../SKILL.md"; then + echo "❌ Error: Missing 'description' field" + exit 1 +fi + +echo "✅ Skill validation passed"