ai-simplify
$
npx mdskill add arcasilesgroup/ai-engineering/ai-simplifyDiscoverable wrapper around the `ai-simplify` agent: dispatches the agent via the Agent tool, validates after every change, applies the self-check protocol, and reports the simplifications made. On-demand only — there is no scheduling, no PR-opening side effect, no auto-commit. The complement of `/ai-simplify-sweep` (which IS scheduled, IS repo-wide, and DOES open a draft PR).
SKILL.md
.github/skills/ai-simplifyView on GitHub ↗
---
name: ai-simplify
description: On-demand code simplification — guard clauses, method extraction, nesting flattening, dead code removal, conditional simplification. Behavior preserved; tests pass after every change. Scoped to operator-chosen files or current diff. No PR, no auto-commit. Trigger for 'simplify this file', 'reduce complexity here', 'clean up the in-flight diff', 'flatten this nesting'. Not for scheduled repo-wide sweeps — use /ai-simplify-sweep. Not for structural changes (file moves, renames) — use /ai-refactor.
effort: mid
argument-hint: "[paths|--diff] [--conservative|--aggressive]"
mode: agent
tags: [refactor, complexity, simplification]
model_tier: sonnet
mirror_family: copilot-skills
generated_by: ai-eng sync
canonical_source: .claude/skills/ai-simplify/SKILL.md
edit_policy: generated-do-not-edit
---
# Simplify
Discoverable wrapper around the `ai-simplify` agent: dispatches the agent via the Agent tool, validates after every change, applies the self-check protocol, and reports the simplifications made. On-demand only — there is no scheduling, no PR-opening side effect, no auto-commit. The complement of `/ai-simplify-sweep` (which IS scheduled, IS repo-wide, and DOES open a draft PR).
## Quick start
```
/ai-simplify # current diff, default aggressiveness
/ai-simplify src/auth/login.py # scoped to a single file
/ai-simplify src/auth/ --conservative # scoped to directory, conservative
/ai-simplify --diff --aggressive # current diff, aggressive defaults
```
## Workflow
Principles applied: §10.1 KISS (the simplified version must actually be simpler — not just different; the self-check protocol enforces it); §10.7 Clean Code (names tell the story, functions do one thing well, cyclomatic complexity ≤8 per the engineering principles).
1. **Step 0** — load stack contexts: read `.ai-engineering/manifest.yml` `providers.stacks` and apply `.ai-engineering/overrides/<stack>/conventions.md` so the stack-specific linter is wired up before any edit.
2. **Detect target** — `$ARGUMENTS` resolves to one of: explicit paths, `--diff` (current staged changes), or empty (current diff is the default).
3. **Dependency preflight** — verify `.github/agents/simplify.agent.md` is on disk. STOP and report the exact missing path if absent.
4. **Dispatch** — invoke the `ai-simplify` agent via the Agent tool with `{paths, aggressiveness}`. The agent runs in its own context window. The agent applies guard clauses, extracts methods, flattens nesting, removes dead code, simplifies conditionals — and validates after EVERY change (stack-specific linter + tests if fast).
5. **Self-check** — for each simplification the agent applies, the self-check protocol must answer favourably: (a) is the simplified version actually simpler, or just different? (b) would a newcomer find the new version easier to understand? (c) did the change introduce a new abstraction — and if so, does it earn its existence? (d) am I reducing complexity or just moving it somewhere else? Any unfavourable answer → revert.
6. **Render report** — emit the simplification report grouped by file, with columns `File | Change | Complexity Before | After | Lines Saved`.
7. **No PR, no commit** — `/ai-simplify` is the in-flight lane. The operator owns the next commit. (The scheduled `/ai-simplify-sweep` is the lane that opens a draft PR.)
## When to Use
- Mid-feature, when a function you just wrote feels deeper than it should be.
- After a code-review round that flagged complexity above the cyclomatic ≤10 or cognitive ≤15 threshold.
- When you want to reduce nesting or extract a helper before shipping the current diff.
- NOT for repo-wide entropy sweeps — those are `/ai-simplify-sweep` territory (scheduled, draft-PR, conservative-only).
- NOT for structural changes (moves, renames, splits) — that is refactor work, not simplification.
## Distinction from /ai-simplify-sweep
| Aspect | `/ai-simplify` (this skill) | `/ai-simplify-sweep` (existing) |
|---|---|---|
| Invocation | On-demand by operator | Scheduled (weekly cron, `/ai-schedule`) |
| Scope | Operator-chosen paths or current diff | Repo-wide sweep |
| PR behaviour | No PR (in-flight work) | Always opens draft PR |
| Auto-commit | No (operator owns next commit) | Yes (`/ai-commit` before PR) |
| Aggressiveness | Operator-chosen (`--conservative` / `--aggressive`) | Conservative-only |
| Telemetry | `framework_event kind=simplify_ondemand_run` | `framework_event kind=simplify_sweep_*` |
The two skills share the same `ai-simplify` agent engine. They differ in invocation cadence, scope, and post-conditions — not in the actual simplification logic.
## Output Contract
```markdown
## Simplification Report
| File | Change | Complexity Before | After | Lines Saved |
|------|--------|-------------------|-------|-------------|
### Summary
- Files simplified: N
- Total complexity reduction: N points
- Lines removed: N
- All tests passing: YES / NO
```
If `All tests passing: NO`, the skill MUST report the failing test, MUST NOT auto-revert the file (the operator decides whether to keep the partial simplification or roll back), and MUST emit `framework_event kind=simplify_test_regression` so the failure is auditable.
## Boundaries
- **Behaviour MUST be preserved** — same inputs produce same outputs.
- **Tests MUST pass** after every change; if a fast (<30s) test suite exists, run it after each file.
- **Never modifies test files** — tests are the immutable specification; simplification operates on production code only.
- **Never simplifies code already below thresholds** — there is no value in churning compliant code.
- **One file at a time, validate before moving to next** — never batch-apply across multiple files without intermediate validation.
- **External API signatures are immutable** — public function signatures, exported types, and CLI contracts are off-limits; only internals are refactored.
- **No new abstractions** — simplification reduces complexity in existing structure; it does NOT introduce protocols, base classes, or extension points (that is refactor / build territory).
- **No PR, no auto-commit** — the operator owns the resulting diff.
## Examples
### Example 1 — scoped simplification of a single file
User: "simplify src/auth/login.py — the nested if/else is hard to follow"
```
/ai-simplify src/auth/login.py
```
Skill dispatches the `ai-simplify` agent scoped to `src/auth/login.py`. The agent flags three opportunities: (1) the outer `if user is not None` can be inverted into an early-return guard clause, (2) the inner `if user.active` can also be a guard clause, (3) the trailing `else: return None` becomes unreachable. After each edit the agent runs `ruff check src/auth/login.py` + `ruff format --check`. The skill renders the report: 1 file simplified, 3 complexity points reduced, 8 lines removed, all tests passing.
### Example 2 — simplify the current in-flight diff
User: "simplify whatever I have staged before I open the PR"
```
/ai-simplify --diff --conservative
```
Skill dispatches the `ai-simplify` agent in conservative mode against `git diff --staged` output. The agent applies only the safest simplifications (guard clauses, dead-branch removal, single-call-site inlines) — no aggressive refactors. After each edit, validation runs. The skill renders the report. The operator reviews the diff and either commits or selectively rolls back. No PR is opened (that is `/ai-simplify-sweep`'s job).
## Integration
**Called by**: operators directly via `/ai-simplify` (ad-hoc, single-file or
diff-scoped). Not auto-invoked by any other skill.
**Calls**: the `ai-simplify` agent (`.github/agents/simplify.agent.md`) via the
Agent tool with the operator-chosen scope. Validation runs after each edit;
the agent rolls back on test failure (behavior-preserving contract).
**See also**:
- `.github/skills/ai-simplify-sweep/SKILL.md` — scheduled wrapper with draft-PR side effect (different cadence and contract).
- `.ai-engineering/manifest.yml` `quality` section — complexity thresholds the agent consults (cyclomatic ≤10, cognitive ≤15, nesting ≤3, method length ≤50).
- `.ai-engineering/overrides/<stack>/conventions.md` — stack overrides.
- Engineering anchors: CLAUDE.md §10.1 KISS, §10.7 Clean Code.
- D-134-07 (cohesion test — first-class agents must have a discoverable slash-skill).
$ARGUMENTS
More from arcasilesgroup/ai-engineering
- ai-adviseProactive governance advisor — checks standards, decisions, and quality trends during development. Always advisory, NEVER blocks. Three modes: `advise` (post-edit), `gate` (pre-dispatch), `drift` (on-demand decision audit). Trigger for 'governance check', 'advise on this change', 'check for drift', 'is this aligned with active decisions', 'shift-left advisory'. Not for blocking gates — use /ai-verify. Not for narrative code review — use /ai-review.
- ai-analyze-permissionsUse when Claude Code keeps asking to approve commands you have already approved, when settings.local.json has grown large, or when you want to consolidate permission grants into wildcard patterns. Trigger for 'too many permission prompts', 'clean up permissions', 'audit my settings', 'consolidate allow rules'. Claude Code only — not available in GitHub Copilot, Antigravity, or Codex.
- ai-animationDesigns motion, transitions, and micro-interactions for UI components: spring animations, gestures, easing, staggers — taste-driven detail compounding. Trigger for 'animate this', 'add transitions', 'micro-interactions for', 'gesture design', 'swipe to dismiss', 'easing for this', 'stagger the'. Not for design systems; use /ai-design instead. Not for visual art; use /ai-visual instead. Not for testing animation code; use /ai-test instead.
- ai-autopilotDelivers large multi-concern specs and backlog runs autonomously: decomposes specs into sub-specs (or normalizes work items into a backlog DAG), deep-plans with parallel agents, builds a dependency DAG, implements in waves, runs a single final quality loop with one bounded quality-remediation pass (verify+guard+review on full changeset), delivers via PR. Trigger for 'implement spec-NNN end to end', 'autopilot this', 'autonomous delivery', 'decompose and ship', 'run the backlog', 'execute these GitHub issues', 'process the sprint backlog'. Invocation is the approval gate. Not for small or single-concern tasks; use /ai-build instead. Not for ambiguous requirements; use /ai-brainstorm first.
- ai-boardOperates the project board (GitHub Projects v2 or Azure DevOps): discovers configuration after install (fields, state mappings, process templates) and syncs work-item state at lifecycle transitions. Trigger for 'set up the board', 'configure our ADO board', 'discover board fields', 'move this issue to in-review', 'update the board', 'mark as in progress', 'sync the work item state'. Two subcommands: `discover` (post-install configuration write) and `sync` (lifecycle state transitions). Auto-invoked via `sync` by /ai-brainstorm, /ai-build, and /ai-pr; fail-open. Not for backlog execution; use /ai-autopilot --backlog instead.
- ai-brainstormForces rigorous design interrogation BEFORE any code: explores approaches, surfaces ambiguity, gathers evidence, produces an approved spec that becomes the contract for /ai-plan. Trigger for 'lets add X', 'how should we handle Y', 'whats the best approach', 'I am thinking about', 'what should we build for'. Not for existing approved specs; use /ai-plan instead. Not for execution; use /ai-build instead.
- ai-branch-cleanupCleans branches safely: switches to the default branch, prunes merged and squash-merged branches, syncs to remote, sweeps stale specs, rotates `.ai-engineering/runtime/` per retention policy. Trigger for 'tidy up', 'tidy branches', 'sync to main', 'delete old branches', 'start fresh', 'rotate runtime'. Auto-invoked by /ai-pr after merge. Not for committing changes; use /ai-commit instead. Not for code-level dead-code removal; use /ai-simplify instead.
- ai-buildCanonical implementation gateway: reads approved plan.md, resolves stack from manifest, deterministic-routes each task to its adapter, dispatches the build agent in an isolated worktree, runs TDD self-validation per task, then a single final quality loop with one bounded quality-remediation pass on the full changeset before /ai-pr. Trigger for 'go', 'start building', 'execute the plan', 'implement it', 'lets do this', 'build the plan', 'resume', 'continue'. Not without an approved plan; run /ai-plan first. Not for multi-concern specs needing decomposition; use /ai-autopilot instead. Not for a single function or subcomponent; use /ai-code.
- ai-codeWrites production code that satisfies stack-context standards on the first pass: interface-first design, backward-compatibility checks, lightweight self-review. Trigger for 'implement this', 'write the code for', 'add X to Y', 'build this function', 'make this work'. Not for tests; use /ai-test instead. Not for debugging; use /ai-debug instead. Not for refactoring; use /ai-simplify instead. Not for executing an approved plan end-to-end; use /ai-build (the gateway).
- ai-commitRuns the governed commit pipeline: auto-branches from protected, stages selectively, formats and lints, scans for secrets, gates docs, composes a conventional message, pushes. Trigger for 'commit my changes', 'save my work', 'push this to remote', 'stage these files', 'ship it'. Not for opening a PR; use /ai-pr instead. Not for branch hygiene; use /ai-branch-cleanup instead.