Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/getsentry/warden/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The --fix flag enables auto-fix mode, where Warden applies suggested fixes from findings automatically.

Usage

warden --fix [targets...] [options]

How It Works

1

Run analysis

Warden analyzes your code and identifies issues with suggested fixes.
2

Review fixes

In interactive mode (default), you review each fix:
πŸ”§ Apply fix for src/api/users.ts:45?

Missing error handling in async function

-  const user = await db.users.findOne({ id });
+  const user = await db.users.findOne({ id }).catch(err => {
+    console.error('Failed to fetch user:', err);
+    throw err;
+  });

Apply this fix? (y/n/q)
3

Apply patches

Warden applies unified diff patches to your files.
4

Verify changes

Review applied changes with git diff.

Options

β€”yes, -y

Auto-apply all fixes without confirmation:
warden --fix --yes
This applies all fixes automatically. Review changes afterward with git diff.

β€”no, -n

Dry run - show what would be fixed without applying:
warden --fix --no

β€”max-findings

Limit number of fixes to apply:
warden --fix --max-findings 5

Interactive Mode

By default, --fix runs interactively:
npx warden --fix

Prompts

For each fixable finding:
πŸ”§ Apply fix for src/api/users.ts:45?

Missing error handling in async function

--- src/api/users.ts
+++ src/api/users.ts
@@ -42,7 +42,10 @@
 
 async function getUser(id: string) {
-  const user = await db.users.findOne({ id });
+  const user = await db.users.findOne({ id }).catch(err => {
+    console.error('Failed to fetch user:', err);
+    throw err;
+  });
   return user;
 }

Apply this fix? (y/n/q)

Responses

  • y (yes): Apply this fix
  • n (no): Skip this fix
  • q (quit): Exit without applying more fixes

Examples

Interactive fix mode

$ npx warden --fix

⚑ Warden v0.18.0

πŸ” Running 2 skills on 5 files...

βœ“ code-quality: 3 findings (2 fixable)
πŸ”§ Found 2 fixable findings

πŸ”§ Apply fix for src/api/users.ts:45?

Missing error handling

--- src/api/users.ts
+++ src/api/users.ts
@@ -42,3 +42,5 @@
-  const user = await db.users.findOne({ id });
+  const user = await db.users.findOne({ id }).catch(err => {
+    throw new Error(`User not found: ${err.message}`);
+  });

Apply this fix? (y/n/q) y
βœ“ Applied fix to src/api/users.ts

πŸ”§ Apply fix for src/utils/jwt.ts:89?

Weak signature algorithm

--- src/utils/jwt.ts
+++ src/utils/jwt.ts
@@ -86,2 +86,2 @@
-  algorithm: 'HS256',
+  algorithm: 'RS256',

Apply this fix? (y/n/q) y
βœ“ Applied fix to src/utils/jwt.ts

βœ“ Applied 2 fixes

Auto-apply all fixes

$ npx warden --fix --yes

⚑ Warden v0.18.0

πŸ” Running 2 skills on 5 files...

βœ“ code-quality: 3 findings (2 fixable)
πŸ”§ Applying 2 fixes...

βœ“ Applied fix to src/api/users.ts
βœ“ Applied fix to src/utils/jwt.ts

βœ“ Applied 2 fixes

Review changes with:
  git diff

Fix specific files

npx warden --fix src/api/

Dry run

$ npx warden --fix --no

πŸ”§ Found 2 fixable findings (dry run)

  src/api/users.ts:45 - Missing error handling [medium]
  src/utils/jwt.ts:89 - Weak signature algorithm [high]

Run 'warden --fix' to apply these fixes

Fix Format

Fixes use unified diff format:
--- src/api/users.ts
+++ src/api/users.ts
@@ -42,3 +42,5 @@
 
 async function getUser(id: string) {
-  const user = await db.users.findOne({ id });
+  const user = await db.users.findOne({ id }).catch(err => {
+    throw new Error(`User not found: ${err.message}`);
+  });
   return user;
 }
  • Lines starting with - are removed
  • Lines starting with + are added
  • Context lines show surrounding code

Verification

After applying fixes:

Review changes

git diff

Test your code

npm test
npm run build

Commit changes

git add -A
git commit -m "fix: apply Warden suggestions"

Error Handling

Patch application failures

If a patch fails to apply:
βœ— Failed to apply fix to src/api/users.ts:
  Patch does not match current file contents
Causes:
  • File was modified since analysis
  • Conflicting changes in the same area
  • File encoding issues
Solution:
  1. Run analysis again: npx warden --fix
  2. Manually apply the fix
  3. Skip the fix and continue

No fixable findings

πŸ” No fixable findings
Not all findings have suggested fixes. Skills must explicitly provide fix diffs.

Tips

Always review with git diff before committing:
npx warden --fix
git diff
npm test
git commit -am "fix: apply Warden suggestions"
Fix high-severity issues first:
# Fix high severity only
npx warden --fix --fail-on high

# Then fix medium
npx warden --fix --fail-on medium
Fix specific areas:
# Fix only API files
npx warden --fix src/api/

# Fix specific file
npx warden --fix src/api/users.ts
Auto-fixing in CI requires careful consideration:
# Create fix PR automatically
- name: Apply fixes
  run: npx warden --fix --yes
  if: github.event_name == 'schedule'

- name: Create PR
  run: |
    git checkout -b warden-fixes-$(date +%s)
    git commit -am "fix: apply Warden suggestions"
    gh pr create --title "Warden fixes" --body "Auto-generated fixes"

Limitations

Not all findings are fixable

Skills must explicitly provide fix diffs. Some issues require human judgment:
  • Architectural changes
  • Logic errors
  • Complex refactorings

Fixes may conflict

Multiple fixes to the same area may conflict. Review carefully.

Test after fixing

Auto-fixes don’t guarantee correctness. Always test:
npx warden --fix --yes
npm test

Main command

Analyze without fixing

Findings

Understanding finding structure

Creating skills

Add suggested fixes to your skills

Output formats

JSONL format includes fix diffs