Practical Lesson 4 of 7

Prompting That Works

Output quality is a direct function of input quality. Prompt engineering — the discipline of structuring inputs for optimal model performance — is a prerequisite for effective Claude Code usage.

Principle: output quality is bounded by input quality. No model configuration compensates for an underspecified prompt.

Effective Prompt Characteristics

  • Specificity: "Build auth" is underspecified. "Session-based auth with bcrypt, PostgreSQL session storage, HTTP-only cookies" constrains the implementation space to the intended design.
  • Negative constraints: Explicitly prohibiting undesired patterns ("no unnecessary abstractions", "no dependency injection framework") prevents the model's tendency toward over-engineering.
  • Contextual rationale: "This runs on every request" fundamentally alters the model's optimization criteria. Performance context shapes architectural decisions.

Over-engineering bias: LLMs exhibit a systematic tendency toward over-abstraction. Explicit simplicity constraints ("minimal implementation", "no speculative abstractions") are necessary to counteract this bias.

Prompt Structure Hierarchy

Empirically, prompts are most effective when they follow this priority order:

  1. Specificity over vagueness — reduce ambiguity in requirements
  2. Constraints over open-ended requests — bound the solution space
  3. Examples over descriptions — concrete patterns outperform abstract specifications

A working code example communicates intent with significantly higher fidelity than a verbal description. When feasible, providing a minimal reference implementation is the most effective prompting strategy.

Model Selection: Claude 4 Family

Opus

Highest-accuracy reasoning. Optimal for complex planning, architecture decisions, and debugging problems that require deep analysis. Higher latency and cost.

Sonnet

Balanced accuracy and speed. Recommended as the default for implementation tasks where the approach is established. Lower latency and cost.

Haiku

Optimized for speed and cost efficiency. Suitable for high-volume, well-defined tasks such as formatting, simple refactoring, and boilerplate generation.

Recommended workflow: Use Opus for planning and architectural design, then switch to Sonnet or Haiku for implementation. The /fast command toggles fast output mode within the same model tier.

Key Takeaways

  • Output quality is bounded by input specificity
  • Specificity, constraints, and examples form the prompt effectiveness hierarchy
  • Negative constraints counteract the model's over-engineering bias
  • Claude 4 Opus for planning; Sonnet for implementation; Haiku for high-volume tasks