Guide

Prompt engineering for AI coding agents

A practical guide to prompt engineering for AI coding agents, including task scoping, context windows, review loops, and repeatable workflows.

Quick framework

  1. Scope tasks to a single, reviewable change.
  2. Provide the exact files and context the agent needs.
  3. Specify constraints: language version, style, test framework.
  4. Require the agent to run tests and report results.
  5. Review diffs before merging — never trust generated code blindly.

Prompt patterns that work

PatternExample
Task + constraints"Add a rate limiter to the API using token bucket. Use Redis for state. Include unit tests with pytest."
Refactor with tests"Extract the auth logic from routes.py into auth.py. Run existing tests and add coverage for edge cases."
Bug fix with reproduction"Fix the N+1 query in User.get_posts(). Here's the failing test. Keep the fix minimal."
Explain then edit"First explain the current caching strategy, then propose and implement improvements."
Independence note: Aoki is independent and not affiliated with any listed vendor. Product names are used descriptively. Confirm current pricing, availability, and setup details with official sources.