repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | # Prompt Engineering Guide |
| #2 | |
| #3 | ## Introduction |
| #4 | |
| #5 | Effective prompts are the foundation of powerful AI agents. This guide teaches you how to craft system prompts that produce consistent, high-quality results. |
| #6 | |
| #7 | ## Prompt Structure |
| #8 | |
| #9 | ### Basic Framework |
| #10 | |
| #11 | ``` |
| #12 | [IDENTITY] + [CAPABILITIES] + [GUIDELINES] + [FORMAT] + [EXAMPLES] |
| #13 | ``` |
| #14 | |
| #15 | ### Identity |
| #16 | |
| #17 | Define who/what the agent is: |
| #18 | |
| #19 | ``` |
| #20 | You are a DeFi security auditor specializing in Ethereum smart contracts. |
| #21 | ``` |
| #22 | |
| #23 | Clear identity creates consistent behavior and sets user expectations. |
| #24 | |
| #25 | ### Capabilities |
| #26 | |
| #27 | List specific skills and knowledge: |
| #28 | |
| #29 | ``` |
| #30 | CAPABILITIES: |
| #31 | - Analyze Solidity code for common vulnerabilities |
| #32 | - Check for reentrancy, overflow, and access control issues |
| #33 | - Review token economics and minting mechanisms |
| #34 | - Assess gas optimization opportunities |
| #35 | ``` |
| #36 | |
| #37 | ### Guidelines |
| #38 | |
| #39 | Behavior rules and constraints: |
| #40 | |
| #41 | ``` |
| #42 | GUIDELINES: |
| #43 | - Classify risks as Critical/High/Medium/Low |
| #44 | - Provide code snippets showing vulnerabilities |
| #45 | - Suggest specific fixes with examples |
| #46 | - Never guarantee 100% security |
| #47 | - Recommend professional audits for production code |
| #48 | ``` |
| #49 | |
| #50 | ### Output Format |
| #51 | |
| #52 | Structure for responses: |
| #53 | |
| #54 | ``` |
| #55 | FORMAT: |
| #56 | Security Score: [0-100] |
| #57 | Critical Issues: [List] |
| #58 | Recommendations: [Prioritized steps] |
| #59 | Code Examples: [Where applicable] |
| #60 | ``` |
| #61 | |
| #62 | ### Examples |
| #63 | |
| #64 | Demonstrate desired behavior (optional but powerful): |
| #65 | |
| #66 | ``` |
| #67 | EXAMPLE: |
| #68 | User: "Check this function for issues" |
| #69 | You: "Security Score: 65/100 |
| #70 | |
| #71 | Critical Issues: |
| #72 | 1. Reentrancy vulnerability on line 45 |
| #73 | - Current: function withdraw() external { ... } |
| #74 | - Fix: Add nonReentrant modifier |
| #75 | |
| #76 | Recommendations: |
| #77 | 1. Implement checks-effects-interactions pattern |
| #78 | 2. Add reentrancy guard |
| #79 | 3. Consider using OpenZeppelin's ReentrancyGuard" |
| #80 | ``` |
| #81 | |
| #82 | ## Writing Clear Prompts |
| #83 | |
| #84 | ### Be Specific |
| #85 | |
| #86 | ❌ Vague: "You help with DeFi" |
| #87 | ✅ Clear: "You analyze yield farming strategies across Ethereum Layer 2 protocols, focusing on risk-adjusted returns" |
| #88 | |
| #89 | ### Use Action Verbs |
| #90 | |
| #91 | ✅ Analyze, Calculate, Compare, Evaluate, Recommend, Monitor, Optimize |
| #92 | |
| #93 | ### Set Boundaries |
| #94 | |
| #95 | ``` |
| #96 | IN SCOPE: |
| #97 | - Ethereum mainnet and L2s (Arbitrum, Optimism, Base) |
| #98 | - Established protocols (TVL > $10M) |
| #99 | - Yield strategies up to medium risk |
| #100 | |
| #101 | OUT OF SCOPE: |
| #102 | - Unaudited contracts |
| #103 | - New protocols (< 3 months old) |
| #104 | - High-risk leveraged positions |
| #105 | - Tax or legal advice |
| #106 | ``` |
| #107 | |
| #108 | ## Advanced Techniques |
| #109 | |
| #110 | ### Conditional Logic |
| #111 | |
| #112 | ``` |
| #113 | IF user provides wallet address: |
| #114 | - Fetch on-chain data |
| #115 | - Analyze current positions |
| #116 | - Provide personalized recommendations |
| #117 | |
| #118 | IF user asks about specific protocol: |
| #119 | - Check TVL and audit status |
| #120 | - Analyze recent activity |
| #121 | - Provide risk assessment |
| #122 | |
| #123 | IF query is unclear: |
| #124 | - Ask 2-3 clarifying questions |
| #125 | - Don't make assumptions |
| #126 | ``` |
| #127 | |
| #128 | ### Tone and Personality |
| #129 | |
| #130 | ``` |
| #131 | COMMUNICATION STYLE: |
| #132 | - Professional but approachable |
| #133 | - Use analogies for complex concepts |
| #134 | - Acknowledge uncertainty when appropriate |
| #135 | - Encourage user questions |
| #136 | ``` |
| #137 | |
| #138 | For DeFi agents, balance between: |
| #139 | |
| #140 | - **Technical accuracy** (for experienced users) |
| #141 | - **Accessibility** (for newcomers) |
| #142 | |
| #143 | ### Error Handling |
| #144 | |
| #145 | ``` |
| #146 | WHEN USER REQUEST IS OUT OF SCOPE: |
| #147 | "I specialize in yield optimization for established protocols. For [user's topic], I recommend consulting [appropriate resource]." |
| #148 | |
| #149 | WHEN DATA IS UNAVAILABLE: |
| #150 | "I don't have real-time data on that protocol. I can explain the general mechanism, or you can check [reliable source]." |
| #151 | |
| #152 | WHEN RISKS ARE HIGH: |
| #153 | "⚠️ High Risk Alert: This strategy involves [specific risks]. Only proceed if you understand and can afford potential losses." |
| #154 | ``` |
| #155 | |
| #156 | ## Domain-Specific Tips |
| #157 | |
| #158 | ### DeFi Prompts |
| #159 | |
| #160 | Include: |
| #161 | |
| #162 | - Risk disclaimers |
| #163 | - Gas cost considerations |
| #164 | - Smart contract audit status |
| #165 | - Impermanent loss warnings |
| #166 | - Slippage and MEV awareness |
| #167 | |
| #168 | ``` |
| #169 | RISK DISCLAIMER: |
| #170 | Always append to financial recommendations: |
| #171 | "Not financial advice. Smart contract risks exist. Only invest what you can afford to lose. DYOR." |
| #172 | ``` |
| #173 | |
| #174 | ### Trading Agents |
| #175 | |
| #176 | ``` |
| #177 | NEVER: |
| #178 | - Guarantee profits or outcomes |
| #179 | - Provide specific entry/exit prices |
| #180 | - Recommend leverage without risk warnings |
| #181 | - Ignore market context |
| #182 | |
| #183 | ALWAYS: |
| #184 | - Include multiple scenarios (bull/bear/sideways) |
| #185 | - Show supporting data/charts |
| #186 | - Explain reasoning transparently |
| #187 | - Suggest position sizing |
| #188 | ``` |
| #189 | |
| #190 | ### Technical Agents |
| #191 | |
| #192 | ``` |
| #193 | CODE REVIEW STRUCTURE: |
| #194 | 1. High-level assessment |
| #195 | 2. Line-by-line analysis |
| #196 | 3. Security concerns |
| #197 | 4. Gas optimizations |
| #198 | 5. Best practice recommendations |
| #199 | 6. Suggested improvements with code |
| #200 | ``` |
| #201 | |
| #202 | ## Testing Your Prompts |
| #203 | |
| #204 | ### Test Suite |
| #205 | |
| #206 | Try these scenarios: |
| #207 | |
| #208 | 1. **Happy Path**: Standard, clear request |
| #209 | 2. **Ambiguous**: Vague or unclear query |
| #210 | 3. **Out of Scope**: Request beyond agent's expertise |
| #211 | 4. **Edge Case**: Unusual or complex situation |
| #212 | 5. **Adversarial**: Attempt to break agent behavior |
| #213 | |
| #214 | ### Iterative Refinement |
| #215 | |
| #216 | ``` |
| #217 | Version 1: Basic prompt |
| #218 | ↓ |
| #219 | Test with users |
| #220 | ↓ |
| #221 | Identify issues: Too verbose? Missing context? Inconsistent? |
| #222 | ↓ |
| #223 | Version 2: Refined prompt |
| #224 | ↓ |
| #225 | Test again |
| #226 | ↓ |
| #227 | Version 3: Optimized prompt |
| #228 | ``` |
| #229 | |
| #230 | ## Common Pitfalls |
| #231 | |
| #232 | ### ❌ Too Broad |
| #233 | |
| #234 | "You help with cryptocurrency" |
| #235 | → Too vague, leads to inconsistent behavior |
| #236 | |
| #237 | ### ❌ Too Narrow |
| #238 | |
| #239 | "You only calculate APY for Uniswap V2 ETH/USDC pools on Thursdays" |
| #240 | → Overly specific, not useful |
| #241 | |
| #242 | ### ❌ Contradictory |
| #243 | |
| #244 | "Be concise. Provide detailed explanations with examples." |
| #245 | → Conflicting instructions confuse the model |
| #246 | |
| #247 | ### ❌ Assuming Knowledge |
| #248 | |
| #249 | Referring to concepts without defining them |
| #250 | → Explain or link to definitions |
| #251 | |
| #252 | ## Prompt Templates |
| #253 | |
| #254 | ### General Purpose |
| #255 | |
| #256 | ``` |
| #257 | You are [ROLE] with expertise in [DOMAIN]. |
| #258 | |
| #259 | Your core functions: |
| #260 | 1. [Function 1] |
| #261 | 2. [Function 2] |
| #262 | 3. [Function 3] |
| #263 | |
| #264 | When responding: |
| #265 | - [Guideline 1] |
| #266 | - [Guideline 2] |
| #267 | - [Guideline 3] |
| #268 | |
| #269 | Format your responses as: |
| #270 | [Structure description] |
| #271 | ``` |
| #272 | |
| #273 | ### Analytical Agent |
| #274 | |
| #275 | ``` |
| #276 | You are a [TYPE] analyst for [DOMAIN]. |
| #277 | |
| #278 | ANALYSIS FRAMEWORK: |
| #279 | 1. Data Collection: [Sources] |
| #280 | 2. Processing: [Methods] |
| #281 | 3. Interpretation: [Approach] |
| #282 | 4. Recommendation: [Format] |
| #283 | |
| #284 | DELIVERABLES: |
| #285 | - Summary (2-3 sentences) |
| #286 | - Detailed analysis |
| #287 | - Risk assessment |
| #288 | - Actionable insights |
| #289 | |
| #290 | CONFIDENCE LEVELS: |
| #291 | - High: Strong supporting evidence |
| #292 | - Medium: Reasonable evidence |
| #293 | - Low: Limited or conflicting data |
| #294 | ``` |
| #295 | |
| #296 | ### Educational Agent |
| #297 | |
| #298 | ``` |
| #299 | You are a [TOPIC] educator specializing in [AUDIENCE LEVEL]. |
| #300 | |
| #301 | TEACHING APPROACH: |
| #302 | - Start with fundamentals |
| #303 | - Build complexity gradually |
| #304 | - Use analogies and examples |
| #305 | - Check understanding with questions |
| #306 | - Provide resources for deeper learning |
| #307 | |
| #308 | FORMAT: |
| #309 | 1. Concept explanation (ELI5) |
| #310 | 2. Technical details |
| #311 | 3. Practical example |
| #312 | 4. Common misconceptions |
| #313 | 5. Further reading |
| #314 | ``` |
| #315 | |
| #316 | ## Resources |
| #317 | |
| #318 | - [OpenAI Prompt Engineering Guide](https://platform.openai.com/docs/guides/prompt-engineering) |
| #319 | - [Anthropic Prompting Guide](https://docs.anthropic.com/claude/docs/prompt-engineering) |
| #320 | - [Learn Prompting](https://learnprompting.org/) |
| #321 | |
| #322 | ## Examples from Top Agents |
| #323 | |
| #324 | See `/src/` directory for 505 example agents with proven prompts across various domains. |
| #325 | |
| #326 | --- |
| #327 | |
| #328 | **Questions?** Open an issue or join our Discord community. |
| #329 | |
| #330 | |
| #331 |