Learn practical AI prompting techniques to enhance your coding workflow and get better results from AI coding assistants.
This guide helps developers leverage AI tools effectively in their coding workflow. Whether you’re using Cursor, GitHub Copilot, or other AI assistants, these strategies will help you get better results and integrate AI smoothly into your development process.
AI coding assistants have what’s called a “context window” - the amount of text they can “see” and consider when generating responses. Think of it as the AI’s working memory:
Most modern AI assistants can process thousands of tokens (roughly 4-5 words per token)
Everything you share and everything the AI responds with consumes this limited space
Once the context window fills up, parts of your conversational history may be lost.
This is why providing relevant context upfront is crucial - the AI can only work with what it can “see” in its current context window.
Prioritize relevant information: Focus on sharing the most important details first
Remove unnecessary content: Avoid pasting irrelevant code or documentation
Structure your requests: Use clear sections and formatting to make information easy to process
Reference external resources: For large codebases, consider sharing only the most relevant files
For larger projects, create and reference a central documentation file that summarizes key information, rather than repeatedly explaining the same context.
Cursor Rules allow you to provide consistent context to Cursor AI, making it more effective at understanding your codebase and providing relevant suggestions.
A comprehensive instructions file helps AI tools understand your project better. This should be created early in your project and updated regularly.Ready-to-Use Prompt for Creating Instructions.md:
Copy
Ask AI
Create a detailed instructions.md file for my project with the following sections:1. Overview: Summarize the project goals, problem statements, and core functionality2. Tech Stack: List all technologies, libraries, frameworks with versions3. Project Structure: Document the file organization with explanations4. Coding Standards: Document style conventions, linting rules, and patterns5. User Stories: Key functionality from the user perspective6. APIs and Integrations: External services and how they connect
Be Specific and Direct
Start with clear commands and be specific about what you want. AI tools respond best to clear, direct instructions.
Example: ❌ “Help me with my code”
✅ “Refactor this authentication function to use async/await instead of nested then() calls”Provide Context for Complex TasksReady-to-Use Prompt:
Copy
Ask AI
I'm working on a onchainkit project using [frameworks/libraries]. I need your help with:1. Problem: [describe specific issue]2. Current approach: [explain what you've tried]3. Constraints: [mention any technical limitations]4. Expected outcome: [describe what success looks like]Here's the relevant documentation @https://docs.base.org/onchainkit/llms.txt
Ask for IterationsStart simple and refine through iterations rather than trying to get everything perfect in one go.Ready-to-Use Prompt:
Copy
Ask AI
Let's approach this step by step:1. First, implement a basic version of [feature] with minimal functionality2. Then, we'll review and identify areas for improvement3. Next, let's add error handling and edge cases4. Finally, we'll optimize for performancePlease start with step 1 now.
The OnchainKit project provides optimized documentation in the form of LLMs.txt files. These files are specifically formatted to be consumed by AI models:
Use OnchainKit Documentation
2.Find the component you want to implement
3.Copy the corresponding LLMs.txt url
4.Paste it into your prompt to provide context
Example LLMs.txt Usage:
Copy
Ask AI
I'm implementing a swap component with OnchainKit. Here's the relevant LLMs.txt:@https://docs.base.org/onchainkit/llms.txtBased on this documentation, please show me how to implement a wallet connector that:1. Swap from base usdc to base th2. Handles connection states properly3. Includes error handling4. Follows best practices for user experience
Component Integration ExampleReady-to-Use Prompt for Token Balance Display:
Copy
Ask AI
I need to implement a new feature in my project.1. Shows the connected wallet's balance of our {ERC20 token}. 2. It Updates when the balance changes.3. Handles loading and error states appropriately4. Follows our project's coding standards5. Update our instructions.md to reflect this new implementation*update the prompt a token of your choice
I'm encountering an issue with my code:1. Expected behavior: [what should happen]2. Actual behavior: [what's happening instead]3. Error messages: [include any errors]4. Relevant code: [paste the problematic code]Please analyze this situation step by step and help me:1. Identify potential causes of this issue2. Suggest debugging steps to isolate the problem3. Propose possible solutions
Ready-to-Use Prompt for Adding Debug Logs:
Copy
Ask AI
I need to debug the following function. Please add comprehensive logging statements that will help me trace:1. Input values and their types2. Function execution flow3. Intermediate state changes4. Output values or errorsHere's my code:[paste your code]
If you’re uncertain how to proceed:Ready-to-Use Clarification Prompt:
Copy
Ask AI
I'm unsure how to proceed with [specific task]. Here's what I know:1. [context about the problem]2. [what you've tried]3. [specific areas where you need guidance]What additional information would help you provide better assistance?
If you’re unsure about something, simply state it clearly:
Copy
Ask AI
I'm not sure how to proceed with this implementation. Could you provide some guidance on possible approaches?
Modern AI assistants have capabilities that you can leverage with these advanced techniques:1. Step-by-step reasoning: Ask the AI to work through problems systematically
Copy
Ask AI
Please analyze this code step by step and identify potential issues.
2. Format specification: Request specific formats for clarity
Copy
Ask AI
Please structure your response as a tutorial with code examples and explanations.
3. Length guidance: Indicate whether you want brief or detailed responses
Copy
Ask AI
Please provide a concise explanation in 2-3 paragraphs.
4. Clarify ambiguities: Help resolve unclear points when you receive multiple options
Copy
Ask AI
I notice you suggested two approaches. To clarify, I'd prefer to use the first approach with {insert language choice here}.