Skip to content

Safe Automated Remediation

qv follows a strict design principle: Diagnose first. Explain second. Fix safely.

Unlike aggressive tools that rewrite code unpredictably, qv fix computes deterministic, reversible remediation plans. You can preview proposed diffs in advance with --dry-run, apply fixes interactively, or automate safe repairs in CI scripts.


1. Basic Usage

# Preview proposed unified color diffs without modifying files
qv fix --diff

# Interactive confirmation prompt before applying each individual fix
qv fix -i
# or
qv fix --interactive

# Preview proposed plan in tabular dry-run mode
qv fix --dry-run

# Automatically apply all safe fixes without prompting
qv fix -y

# Fix only a specific rule (e.g. missing dependencies)
qv fix --rule DEP-002 -y

# Apply fixes and execute package manager sync commands
qv fix --sync -y

2. Unified Diff Preview Mode (--diff)

Before modifying any files on disk, inspect the exact line-by-line changes qv fix proposes using --diff:

qv fix --diff
--- pyproject.toml
+++ pyproject.toml
@@ -8,6 +8,7 @@
 dependencies = [
     "click>=8.0.0",
     "rich>=13.0.0",
+    "httpx>=0.27.0",
 ]

3. Interactive Remediation (-i / --interactive)

Run fixes in interactive step-through mode where each individual diagnostic fix prompts for your explicit approval before mutating configuration or source code:

qv fix -i
[1/2] Apply fix for DEP-002 (Add 'httpx' to pyproject.toml)? [y/N]: y
  + Successfully applied fix to pyproject.toml

[2/2] Apply fix for PKG-001 (Initialize pyproject.toml metadata)? [y/N]: n
  - Skipped fix for PKG-001

4. Safety Guarantees & Remediation Levels

qv classifies fixes into four safety categories:

Fix Category Example Behavior
Safe (Deterministic) Adding missing dependencies to pyproject.toml (DEP-002)
Adding default [project] / [tool.qv] settings (PKG-001)
Applied automatically with -y or after interactive confirmation.
Review Required Removing unimported declared dependencies (DEP-003) Requires explicit review because packages may be used dynamically, as plugins, or as database drivers. Skipped during -y.
Command-Assisted Running uv add or pip install (DEP-001, DEP-005, DEP-006) Proposed as shell commands. Only executed if --sync is explicitly passed.
Manual / Complex Refactoring circular import cycles (IMP-001) Provides architectural refactoring hints and code snippets for human review; no blind mutations.

5. Remediation Plan Inspection (Dry Run)

Running qv fix --dry-run displays a structured table of planned actions:

Found 2 actionable fix(es) (2 safe):

┌────────┬────────────────┬─────────────────────────────────────────────────┬──────────┐
│ Rule   │ Target         │ Description                                     │ Type     │
├────────┼────────────────┼─────────────────────────────────────────────────┼──────────┤
│ DEP-002│ pyproject.toml │ Add 'httpx' to project dependencies             │ modify   │
│ DEP-003│ pyproject.toml │ Remove unused requirement 'requests>=2.31.0'    │ modify   │
└────────┴────────────────┴─────────────────────────────────────────────────┴──────────┘

Dry-run mode enabled. No changes written to disk.

6. Package Manager Auto-Sync

When dependencies are modified, running qv fix --sync automatically calls the detected package manager (uv sync, poetry install, pip install) to keep your active virtual environment in lockstep:

qv fix --sync -y