> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blitzy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rules

> Reusable directives that enforce quality and analysis standards during code generation

Rules are reusable constraints you add to your projects on the platform. Each rule has a **name** (a concise title) and a **description** (the full instruction set the AI follows during code generation). Rules enforce quality dimensions - testing, style, security, performance, and more - consistently across every generation. Rules can be shared with teams, reused across different projects, and applied across different languages depending on how flexible the constraint is.

## How Rules Work

<Steps>
  <Step title="Choose a Rule Template or Write Your Own">
    Browse the templates below for ready-to-use directive descriptions, or write a custom rule from scratch.
  </Step>

  <Step title="Create the Rule on the Platform">
    Create a new rule from the prompting section of your project, or from **Settings > Rules**. Enter the rule's name and paste its description. See the [Rules guide](/prompt-engineering/rules) for detailed steps.
  </Step>

  <Step title="Generate Code">
    The rule is enforced automatically during code generation for that project. No need to repeat it in your prompt.
  </Step>
</Steps>

## When to Use Rules

<Tabs>
  <Tab title="Quality Enforcement">
    * **Test coverage** - ensure tests import and invoke real production code
    * **Code style** - enforce existing architectural patterns and conventions
    * **Backward compatibility** - prevent breaking changes to public APIs and interfaces
  </Tab>

  <Tab title="Security & Performance">
    * **Security prevention** - block common vulnerability patterns like injection, hardcoded secrets, and broken auth
    * **Performance annotations** - require complexity documentation and efficient patterns across all generated code
    * **Risk documentation** - annotate changes to public contracts and schemas with risk and mitigation notes
  </Tab>

  <Tab title="Completeness & Documentation">
    * **Code explainability** - add docstrings and inline comments explaining implementation decisions
    * **API contract documentation** - document consumer contracts, data flow, and side effects inline
    * **Workflow completeness** - prevent dead ends, swallowed errors, and undocumented behavior
  </Tab>
</Tabs>

## Rule Templates

<CardGroup cols={2}>
  <Card title="Require Test Coverage" icon="vial-circle-check" href="/templates/rules/require-test-coverage">
    Enforce tests that import and invoke real production code
  </Card>

  <Card title="Enforce Code Style Patterns" icon="palette" href="/templates/rules/enforce-code-style-patterns">
    Ensure generated code matches existing codebase conventions and architecture
  </Card>

  <Card title="Document Code Explainability" icon="message-lines" href="/templates/rules/document-code-explainability">
    Add docstrings and inline comments explaining implementation decisions
  </Card>

  <Card title="Preserve Backward Compatibility" icon="arrow-rotate-left" href="/templates/rules/preserve-backward-compatibility">
    Prevent breaking changes to existing APIs and interfaces
  </Card>

  <Card title="Prevent Security Vulnerabilities" icon="shield-halved" href="/templates/rules/catalog-security-vulnerabilities">
    Block common vulnerability patterns like injection, hardcoded secrets, and broken auth
  </Card>

  <Card title="Annotate Performance Impact" icon="gauge-high" href="/templates/rules/analyze-performance-impact">
    Require complexity annotations, efficient patterns, and documented trade-offs
  </Card>

  <Card title="Assess Change Risks" icon="triangle-exclamation" href="/templates/rules/assess-change-risks">
    Require inline risk documentation for changes to public contracts and schemas
  </Card>

  <Card title="Preserve User Journey Completeness" icon="route" href="/templates/rules/map-user-journeys">
    Ensure complete workflows with entry points, error handling, and exit paths
  </Card>

  <Card title="Document API Consumer Paths" icon="diagram-project" href="/templates/rules/document-api-consumer-paths">
    Document consumer contracts, data flow, and side effects inline on every endpoint
  </Card>

  <Card title="Prevent Workflow Gaps" icon="magnifying-glass-chart" href="/templates/rules/identify-workflow-gaps">
    Block incomplete flows, swallowed errors, and undocumented behavior
  </Card>
</CardGroup>
