Skip to content

Best Practices

Running a new static analysis scan mid-fix generates new fingerprints and resets your progress.

Recommended workflow:

  1. Run static analysis once
  2. Load SARIF into Sheriff
  3. Fix all issues (or all issues you plan to fix)
  4. Rescan to verify fixes and catch new issues
  5. Repeat if needed

Sheriff groups issues by file for a reason. Jumping between files wastes context and increases the chance of missing issues.

# Good: Complete one file
next → 3 issues in Service.java
[fix all 3]
done fps=[...] → mark all 3
# Bad: Partial fixes
next → 3 issues in Service.java
[fix 1]
done fps=[1] → mark 1
next → returns remaining 2 in Service.java (wastes a tool call)

Filter by rule type for batch efficiency:

// Fix all unused imports first (mechanical, fast)
{"action": "next", "scope": {"rule": "unused*"}}
// Then tackle complex issues
{"action": "next", "scope": {"rule": "DataFlowIssue"}}

Filter by severity for priority:

// Critical bugs first
{"action": "next", "scope": {"severity": "High"}}

After editing code, line numbers shift. Use the snip field to locate issues:

{
"loc": "45:12", // May be wrong after edits
"snip": "if (value != null) {" // Search for this
}

Agent approach:

  1. Note the snip content
  2. Search the file for that snippet
  3. The issue is at that location (regardless of line number)

When fixing multiple issues in a file, work from top to bottom. This minimizes line number drift for remaining issues.

Don’t leave false positives unmarked—they’ll keep appearing:

{"action": "done", "fps": ["fp12345678901234"], "status": "skip"}

When an agent skips issues, it should explain why:

“Marking as false positive: The static analyzer doesn’t see that validateInput() guarantees non-null here.”

Adjust the limit parameter based on issue complexity:

Issue TypeRecommended LimitReason
Unused imports25+ (default)Mechanical, fast
Constant checks10Need context
Null pointer issues3-5Require careful analysis
Security issues1-3Need thorough review
// Quick mechanical fixes
{"action": "next", "scope": {"rule": "unused"}, "limit": 20}
// Complex analysis needed
{"action": "next", "scope": {"rule": "SQL_INJECTION"}, "limit": 2}
{"action": "summary"}

Use the breakdown to:

  • Identify quick wins (high count, simple fixes)
  • Prioritize critical issues (high severity)
  • Estimate effort
{"action": "progress"}

“We’ve fixed 85 of 136 issues (63%). 12 null pointer issues and 39 formatting issues remain.”

Sheriff stores state in .sheriff/ directory. No need to save manually.

State survives:

  • Context compaction
  • Session restart
  • Agent switches

If you need to start fresh, delete the .sheriff/ directory:

Terminal window
rm -rf .sheriff/

Then reload the SARIF file.