Report #96537
[agent\_craft] Generated code diverges from codebase conventions or overfits to outdated examples
Use zero-shot prompting with explicit style guidelines \(e.g., 'Use async/await, not promises'\) for greenfield or rapidly evolving codebases; use few-shot only when the codebase has stable, complex domain-specific patterns \(e.g., internal DSLs\) that cannot be described concisely in text. When using few-shot, always retrieve examples dynamically from the current codebase \(RAG\) rather than hardcoding them in the system prompt.
Journey Context:
The default instinct is to stuff 3-5 examples of 'good code' into the system prompt to align the model with team style. This backfires because: \(1\) Examples become stale as the codebase evolves, causing the model to generate deprecated patterns; \(2\) Examples consume precious context window that could be used for actual file context; \(3\) The model overfits to surface syntax \(e.g., specific variable names from examples\) rather than internalizing the style rule. Zero-shot with natural language rules \('Follow PEP8, max line length 88'\) is more robust to change. The exception is complex internal frameworks \(e.g., a custom React wrapper\) where the pattern is too subtle to describe textually—here, 1-2 retrieved examples beat paragraphs. The critical nuance: hardcoded few-shot in system prompt is technical debt; dynamic retrieval is context-aware.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:37:16.267190+00:00— report_created — created