Skip to main content
charter fix is Charter’s repair command. It is intentionally narrow: it only applies safe, explicit fixes to a small set of supported rules, always shows you a unified diff before writing anything, and backs up existing files before replacing them. The guarantee: Charter always shows you a diff before writing. No silent mutation.
charter fix dry run showing unified diff

charter fix --dry-run — unified diff preview before any file is written

Fixable Rules

Secrets (AE-SEC-001, AE-SEC-002) and dangerous-command findings (AE-CC-001) are never auto-fixed. Charter shows evidence and remediation guidance for these but requires manual action. If you target a rule with no registered fixer, Charter reports that it is not auto-fixable.

Usage

1

Preview every diff

Read each unified diff carefully before accepting it. The dry-run output is identical to what fix would apply.
2

Apply the fixes

Originals are backed up to .charter/backups/<ts>/ before any write. Pure creates (new files) have no prior content to back up.
3

Verify the score improved

Confirm the fixed rules no longer appear as active findings and the score moved in the expected direction.

Flags

string
Explicit repository root. Defaults to the current working directory.
string
Limit the repair to a single rule ID such as AE-MCP-001. When omitted, all fixable findings are planned.
boolean
Print unified diffs without writing any files. Safe to run repeatedly.
boolean
Plan every fixable rule. This is already the default behavior; the flag is accepted for explicitness.
boolean
Skip per-fix confirmation prompts. Because fix is already non-interactive in normal use, this flag is accepted for scripting compatibility.

Backup Mechanism

Before replacing or updating an existing file, Charter copies the previous version into .charter/backups/<ts>/, where <ts> is a compact UTC timestamp such as 20260610T074200Z. The original file’s relative path is preserved inside the backup directory. Pure creates — fixes that write a brand new file where none existed — do not produce a backup because there is no prior content to save. Charter never deletes backup directories automatically. They accumulate across runs and serve as a local audit trail of every mutation fix has applied. To recover a backed-up file:

Exit codes

Use charter fix safely

The diff-first workflow and what fix will never touch.

Fix engine

How fixers are registered and how backups are written.

doctor

Re-score the repo to confirm the fixed rules cleared.