Negative Constraints & Anti-Pattern Prompts
A methodology for formulating prohibitions and explicitly excluding undesirable engineering patterns (Anti-Goals) in system instructions to prevent boilerplate and excessive code (AI Slop).
1. Concept Overview & Systemic Problem
Language models have been trained on trillions of lines of diverse internet code. As a result, they tend to default to the so-called "Mediocre Average" style:
- The model sees a trivial mathematical operation and immediately adds
import _ from 'lodash'to the file, bloating the bundle. - The model encounters a complex TypeScript type and resorts to
// @ts-ignoreoras anyto finish generation faster. - The model generates outdated and redundant comments like
// This function adds two numbers.
Negative Constraints serve as an engineering filter that restricts the model's access to harmful habits and forces it to navigate exclusively through a narrow corridor of clean architecture.
2. Architectural Taxonomy & Mental Model
┌─────────────────────────────────────────────────────────────┐
│ NEGATIVE CONSTRAINTS MATRIX │
├─────────────────────────────────────────────────────────────┤
│ 1. DEPENDENCY HYGIENE: │
│ • NEVER run `npm install <package>` without asking. │
│ • DO NOT import deprecated libraries (Axios, Lodash). │
│ • Use native browser `fetch` and ES6 methods ONLY. │
├─────────────────────────────────────────────────────────────┤
│ 2. CODE QUALITY INVARIANTS: │
│ • BANNED: `any`, `unknown` without type guards. │
│ • BANNED: `console.log` in production-facing code. │
│ • BANNED: Commenting obvious self-explanatory lines. │
├─────────────────────────────────────────────────────────────┤
│ 3. UI / DESIGN SYSTEM RULES: │
│ • NEVER invent custom HEX colors (#ff4422). │
│ • USE predefined Tailwind semantic tokens ONLY. │
│ • NEVER hardcode strings; use i18n translation keys. │
└─────────────────────────────────────────────────────────────┘
3. Technical Pipeline & Internal Mechanics
01. Anti-Placeholder Rule
The rules impose strict penalties:
CRITICAL INSTRUCTION:
Do NOT output placeholders like `// ...existing code...` or `/* rest of implementation */`.
Always provide the FULL drop-in replacement. Truncated outputs are considered system failure.
This completely eradicates the model's tendency to slack off on large files.
02. Prohibition on Creating New Files Without Approval
Agents often have a tendency to "multiply entities": creating 5 small utility files for a single line of code. The rule: "DO NOT create new utility files unless explicitly specified in the RFC" keeps the folder structure compact.
4. Production Engineering Scenarios
- Blind Negation Without Alternatives: If you simply write "Do not use React Router", but do not specify that the project runs on Next.js App Router, the model will get confused and start inventing homemade navigation handlers. Always indicate what to do instead of the prohibited.
- Inflating the Prohibition List: If there are 200 "DO NOT" rules in the system prompt, the model will start to experience action paralysis (Refusal Loop), refusing to respond even to safe prompts.
5. Pitfalls, Common Mistakes & Security
Negative prompting is a tool for establishing clear red lines. The discipline of explicit prohibitions cuts off 80% of cases generating synthetic garbage (AI Slop), maintaining a high culture of the project's codebase.
FAQ: Negative Constraints & Anti-Pattern Prompts
Related terms
Agent Rules (.cursorrules / CLAUDE.md / AGENTS.md)
Machine-readable files of architectural regulations and constraints in the repository that are automatically mounted into the system context of AI agents to prevent codebase degradation.
System Prompt (System Instructions & Metaprompting)
The primary metacontext block of instructions passed at the zero position of the context window, defining the agent's role, safety rules, available tools, and behavioral boundaries.
AI Slop: Codebase Contamination
A systemic phenomenon of codebase degradation due to the mass addition of low-quality, verbose, overly complex, or duplicated code generated by language models without architectural oversight.
Prompt Engineering (Context Architecture & Prompt Engineering)
An engineering discipline focused on structuring system directives, XML markup, semantic delimiters, and examples to achieve deterministic, predictable outcomes from probabilistic models.