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

# detail rules: create, propose, and manage analysis rules

> CLI reference for detail rules: create, propose, list, show, and pull custom analysis rules that teach Detail what patterns to catch.

The `detail rules` command group lets you create, list, inspect, and download custom analysis rules for your repositories. Rules can be used to enforce codebase guardrails.

You can generate a rule from a plain language description, from an existing bug, or from commit SHAs that contain an example bug.

An example use case would be: Detail has found a location where your application logs raw secrets, and you want to find any other bugs of this type, fix them all, and prevent them going forward.

## `detail rules create [REPO]`

Submit a rule creation request for a repository. Rule creation takes time; Detail builds your rule in the background and iterates on it based on what it finds in your codebase until the new rule is working well.

```bash theme={null}
detail rules create [OPTIONS] [REPO]
```

**Arguments**

| Argument | Description                                                                                   |
| -------- | --------------------------------------------------------------------------------------------- |
| `REPO`   | Repository as `owner/repo`, bare repo name, or omitted to infer from the `origin` git remote. |

**Flags**

| Flag                   | Description                                                              |
| ---------------------- | ------------------------------------------------------------------------ |
| `--description <TEXT>` | Plain language description of the pattern to detect.                     |
| `--bug-ids <IDS>`      | Bug IDs to learn from. Comma-separated or repeat the flag.               |
| `--commit-shas <SHAS>` | Commit SHAs to examine for patterns. Comma-separated or repeat the flag. |

<Note>
  At least one of `--description`, `--bug-ids`, or `--commit-shas` is required. You can combine them — for example, provide both a description and bug IDs to give Detail richer context.
</Note>

On success, the command prints a rule creation request ID (`rcr_...`). Use `detail rules requests show <rcr_id>` to poll for completion.

**Examples**

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

# Create a rule from existing bug findings
detail rules create --bug-ids bug_abc123,bug_def456

# Combine a description with commit SHAs
detail rules create --commit-shas abc1234,def5678 --description "SQL injection pattern"

# Target a specific repository explicitly
detail rules create owner/my-repo --description "Detect unvalidated redirects"
```

***

## `detail rules propose [REPO]`

Ask Detail to automatically propose rules based on the repository's existing bug history. Detail reviews your findings and suggests rules that would catch similar patterns in future scans.

```bash theme={null}
detail rules propose [REPO]
```

**Arguments**

| Argument | Description                                                                                   |
| -------- | --------------------------------------------------------------------------------------------- |
| `REPO`   | Repository as `owner/repo`, bare repo name, or omitted to infer from the `origin` git remote. |

On success, the command prints a rule creation request ID. Poll progress with `detail rules requests show`.

**Examples**

```bash theme={null}
# Propose rules for the repo inferred from git remote
detail rules propose

# Propose rules for an explicit repo
detail rules propose owner/my-repo
```

***

## `detail rules requests list [REPO]`

List all rule creation requests for a repository and their current status.

```bash theme={null}
detail rules requests list [OPTIONS] [REPO]
```

**Arguments**

| Argument | Description                                                                                   |
| -------- | --------------------------------------------------------------------------------------------- |
| `REPO`   | Repository as `owner/repo`, bare repo name, or omitted to infer from the `origin` git remote. |

**Flags**

| Flag                | Description                       | Default |
| ------------------- | --------------------------------- | ------- |
| `--format <FORMAT>` | Output format: `table` or `json`. | `table` |

**Examples**

```bash theme={null}
detail rules requests list
detail rules requests list owner/my-repo --format json
```

***

## `detail rules requests show <RCR_ID>`

Show the status and details of a specific rule creation request. Poll this command until the status is `complete` or `failed`.

```bash theme={null}
detail rules requests show <REQUEST_ID>
```

**Arguments**

| Argument     | Description                                   |
| ------------ | --------------------------------------------- |
| `REQUEST_ID` | Rule creation request ID in `rcr_...` format. |

The output includes the request status, creation time, completion time (when available), the inputs you provided, and the IDs of any rules that were created.

**Examples**

```bash theme={null}
detail rules requests show rcr_abc123
```

<Tip>
  If the status is still `pending`, wait a moment and run the command again. Rule creation typically completes within a few minutes.
</Tip>

***

## `detail rules list [REPO]`

List all completed rules for a repository.

```bash theme={null}
detail rules list [OPTIONS] [REPO]
```

**Arguments**

| Argument | Description                                                                                   |
| -------- | --------------------------------------------------------------------------------------------- |
| `REPO`   | Repository as `owner/repo`, bare repo name, or omitted to infer from the `origin` git remote. |

**Flags**

| Flag                | Description                       | Default |
| ------------------- | --------------------------------- | ------- |
| `--format <FORMAT>` | Output format: `table` or `json`. | `table` |

**Examples**

```bash theme={null}
detail rules list
detail rules list owner/my-repo --format json
```

***

## `detail rules show <RULE_ID>`

Show a rule's name, metadata, and full generated content.

```bash theme={null}
detail rules show <RULE_ID>
```

**Arguments**

| Argument  | Description                   |
| --------- | ----------------------------- |
| `RULE_ID` | Rule ID in `rule_...` format. |

**Examples**

```bash theme={null}
detail rules show rule_abc123
```

***

## `detail rules pull <RULE_ID>`

Download a rule's generated files to your local filesystem so you can use them as Claude Code skills.

```bash theme={null}
detail rules pull [OPTIONS] <RULE_ID>
```

**Arguments**

| Argument  | Description                   |
| --------- | ----------------------------- |
| `RULE_ID` | Rule ID in `rule_...` format. |

**Flags**

| Flag             | Description                                                                              | Default           |
| ---------------- | ---------------------------------------------------------------------------------------- | ----------------- |
| `--output <DIR>` | Directory to write the `detail-rules/` folder into. Accepts a relative or absolute path. | `.claude/skills/` |

The command writes all rule files into a `detail-rules/` subdirectory inside the output directory, creating any missing parent directories automatically.

**Examples**

```bash theme={null}
# Pull a rule into the default Claude skills location
detail rules pull rule_abc123

# Pull a rule into a custom directory
detail rules pull rule_abc123 --output ./my-rules/
```

<Tip>
  Pulled rules are stored under `.claude/skills/detail-rules/` by default and work as Claude Code skills. Commit this directory to your repository so the whole team benefits from the same rules.
</Tip>
