Chapter 1 - Effective Prompting for AI Coding Agents
Learn to write prompts that get AI agents to build exactly what you need. Master the feedback loop that turns vague requests into working code.
- Reading time: 15 minutes
- Practical time: 10-15 minutes
Reading
Briefs
Prompt Engineering
- Copilot CLI: Prompt Engineering - General principles for AI coding tools
- Claude Code: Prompting Best Practices - Claude-specific techniques
Agentic Loop
- How Claude Code Works - Understanding how agents work under the hood
The Agentic Loop
When you submit a prompt, the agent doesn't just generate code. It executes a loop:
Gather Context: Reads files, searches codebase, checks documentation
Take Action: Edits files, runs commands, creates new code
Verify Results: Checks test output, validates changes, assesses completion
Loop or Complete: Continues until task is done or hits a blocker
Your job is to write prompts that start this loop effectively and provide feedback that keeps it on track.
Practical
Test these prompts with your AI coding agent to practice effective prompting patterns.
Task 1: Simple Function
Create a JavaScript function that takes an array of numbers and returns only the even numbers.
Include example usage.What to observe:
- Does the agent provide a clear, working solution?
- Is example usage helpful?
Task 2: Add Constraints
Create a JavaScript function that takes an array of numbers and returns only the even numbers.
Use the filter method.
Include JSDoc comments.
Add unit tests.What to observe:
- How does adding context affect the output?
- Does the agent follow all constraints?
Apply these patterns in upcoming chapters where you'll work with real codebases.