Skip to main content
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

1

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.
2

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 for detailed steps.
3

Generate Code

The rule is enforced automatically during code generation for that project. No need to repeat it in your prompt.

When to Use Rules

  • 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

Rule Templates

Require Test Coverage

Enforce tests that import and invoke real production code

Enforce Code Style Patterns

Ensure generated code matches existing codebase conventions and architecture

Document Code Explainability

Add docstrings and inline comments explaining implementation decisions

Preserve Backward Compatibility

Prevent breaking changes to existing APIs and interfaces

Prevent Security Vulnerabilities

Block common vulnerability patterns like injection, hardcoded secrets, and broken auth

Annotate Performance Impact

Require complexity annotations, efficient patterns, and documented trade-offs

Assess Change Risks

Require inline risk documentation for changes to public contracts and schemas

Preserve User Journey Completeness

Ensure complete workflows with entry points, error handling, and exit paths

Document API Consumer Paths

Document consumer contracts, data flow, and side effects inline on every endpoint

Prevent Workflow Gaps

Block incomplete flows, swallowed errors, and undocumented behavior