Prompt Specificity & Precision

Core

Design prompts with explicit criteria to improve precision and reduce false positives · Difficulty 2/5

0%
specificitycriteriaprompting

Vague prompts produce inconsistent results. Prompt specificity means replacing ambiguous instructions with precise criteria that the model can apply deterministically.

Example: Comment Analysis

Vague: "Check that comments are accurate and up-to-date"

  • Flags TODOs, descriptive comments (false positives)
  • Misses genuinely outdated comments (false negatives)
  • Specific: "Flag comments only when their claimed behavior contradicts actual code behavior"

  • Eliminates false positives on acceptable patterns
  • Catches genuinely misleading comments
  • Principles

  • Define criteria, not goals: "Flag contradictions" not "check accuracy"
  • Specify boundaries: What should and should NOT be flagged
  • Use severity definitions: Concrete code examples for each severity level
  • Test with edge cases: Verify the criteria handle ambiguous inputs
  • Key Takeaways

    • Replace vague goals with specific, actionable criteria
    • Define what should NOT be flagged, not just what should
    • Concrete severity criteria with examples improve consistency

    Test Yourself1 of 1

    Your automated review analyzes comments and docstrings. The current prompt instructs Claude to "check that comments are accurate and up-to-date." Findings frequently flag acceptable patterns while missing comments that describe behavior the code no longer implements. What change addresses the root cause?