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

# Rules: Enforce codebase guardrails

> Detail's Rules engine lets you encode project-specific standards into reusable rules and enforce them across your codebase.

Detail's Rules engine lets you create repo-specific rules. Describe a pattern in plain language, via an example bug, via an example commit SHA, and Detail generates a rule. You can use these rules

## How rules work

Detail rules are enforced via an agent skill that's stored in your repository, so you can use it flexibly: as a CI check, or to find existing violations and fix them in bulk. Rules work alongside Detail's built-in bug scanning, so you can turn an individual bug into a guardrail that prevents the whole category of bug from happening.

Rule creation is asynchronous and can take about an hour. Detail tests out the rule against your codebase and iterates on it until the results look correct.

## Creating rules from the CLI

You can create a rule from three kinds of input, or combine them in a single request:

```bash theme={null}
# From a plain-language description
detail rules create --description "Flag any use of console.log in production code"

# From existing bug IDs — Detail uses these as examples of the pattern to detect
detail rules create --bug-ids bug_abc123,bug_def456

# From commit SHAs — Detail examines the commits to extract the underlying pattern
detail rules create --commit-shas abc1234,def5678

# Combine all three for richer context
detail rules create \
  --description "Avoid raw SQL string concatenation" \
  --bug-ids bug_abc123 \
  --commit-shas abc1234
```

After submitting, Detail prints the request ID:

```text theme={null}
✓ Rule creation started.
  Request ID: rcr_01j9x...
  Use 'detail rules requests show <id>' to check progress.
```

## Proposing rules automatically

If you're not sure where to start, let Detail analyze your bug history and propose rules for you:

```bash theme={null}
detail rules propose
```

Detail examines patterns in your existing bugs and generates rule proposals automatically. You receive a request ID and can review the proposed rules once they're ready.

## Checking rule creation status

Rule creation runs asynchronously. Use the `requests` subcommands to track progress:

```bash theme={null}
# List all rule creation requests for the current repo
detail rules requests list

# Check the status of a specific request
detail rules requests show rcr_01j9x...
```

The status field will show the current state of the request, and when it completes you'll see the IDs of the rules that were created.

## Viewing and using rules

Once rules are created, you can inspect and manage them with the following commands:

```bash theme={null}
# List all rules for the current repository
detail rules list

# Read the full content of a specific rule
detail rules show rule_01j9x...

# Download rule files to your local machine
detail rules pull rule_01j9x...
```

`detail rules pull` writes the rule files into `.claude/skills/detail-rules/` in your current directory by default. You can specify a different output directory with `--output`:

```bash theme={null}
detail rules pull rule_01j9x... --output ./my-skills/
```

## Claude Code Skills integration

Rules pulled with `detail rules pull` are written as Claude Code skill files. This means the same patterns Detail uses in your cloud scans can guide your AI coding assistant when writing new code locally — closing the loop between detection and prevention.

<Note>
  Rule creation is asynchronous. After running `detail rules create` or `detail rules propose`, you receive a request ID (`rcr_...`). Poll progress with `detail rules requests show <rcr_id>` and retrieve the finished rule with `detail rules show <rule_id>` once the request completes.
</Note>

## Reference

| Command                               | Description                                                                 |
| ------------------------------------- | --------------------------------------------------------------------------- |
| `detail rules create`                 | Submit a rule creation request using a description, bug IDs, or commit SHAs |
| `detail rules propose`                | Ask Detail to propose rules based on your bug history                       |
| `detail rules list`                   | List all completed rules for the current repository                         |
| `detail rules show <rule_id>`         | Display the content of a specific rule                                      |
| `detail rules pull <rule_id>`         | Download rule files locally into `.claude/skills/detail-rules/`             |
| `detail rules requests list`          | List all rule creation requests for the current repository                  |
| `detail rules requests show <rcr_id>` | Check the status of a specific rule creation request                        |
