Code Simplification (simplification)
Automatically refines recently modified code for clarity before it ships. Based on Anthropic’s internal code-simplifier pattern, it improves how code reads without ever changing what it does.
Core Principle
Clarity over brevity. Functionality preserved absolutely.
Simplification never changes behavior — only readability. All original features, outputs, and behaviors stay intact. It optimizes for the next person to read the code, not for fewer lines.
Configuration
Add to .agent/.nav-config.json:
{
"simplification": {
"enabled": true,
"trigger": "post-implementation",
"scope": "modified",
"model": "opus",
"skip_patterns": ["*.test.*", "*.spec.*", "*.md"],
"auto_apply": false
}
}| Key | Default | Behavior |
|---|---|---|
enabled | true | Master switch for the simplification pass. |
trigger | "post-implementation" | When it runs: "manual", "post-implementation", or "pre-commit". |
scope | "modified" | Which files to consider: "modified", "staged", or "all". Default keeps churn low by touching only recently changed files. |
model | "opus" | Model used for clarity judgment. Opus recommended. |
skip_patterns | ["*.test.*", "*.spec.*", "*.md"] | Glob patterns to skip. Test files follow different conventions; docs and config are excluded. |
auto_apply | false | When false, changes are shown as a diff for approval. When true, edits apply directly. In an autonomous flow with auto_apply: false, the pass is skipped rather than pausing for input. |
What It Changes
- Nested ternaries flattened to
if/elseor a helper function - Deep nesting (over 3 levels) reduced with early returns or extracted functions
- Single-letter or unclear names renamed to descriptive ones
- Redundant boolean comparisons removed (
=== truebecomes a truthy check) - Related logic consolidated, dead code removed
What It Doesn’t Change
- API signatures or public exports
- Test file structure
- Meaningful “why” comments
- Architecture or design patterns
When It Runs
- Autonomous completion: after verify, before commit (if enabled)
- Loop Mode: during the VERIFY phase as a completion indicator
- On-demand: “simplify this code”, “review for clarity”
Example
// Before
const status = isLoading ? 'loading' : hasError ? 'error' : 'idle';
// After
function getStatus(isLoading: boolean, hasError: boolean): string {
if (isLoading) return 'loading';
if (hasError) return 'error';
return 'idle';
}
const status = getStatus(isLoading, hasError);Every pass is instrumented with OpenTelemetry — run /nav:stats to see simplification activity for your own sessions.