Skip to content

dvy1987/agent-loom / .agents/skills/code-simplification

code-simplification

Verified

Simplify application code for clarity without changing behavior — refactor after tests pass, reduce nesting and duplication, match project conventions. Load when refactoring for readability, cleaning up after a feature ships, or when code review flags complexity. Also triggers on "simplify this code", "code simplification", "make this easier to read", "reduce complexity", "refactor for clarity". Not for compress/split/prune-skill (skill-library files). Pairs with technical-debt-audit.

FileKindSize
SKILL.mdskill md5.5 KB
references/examples.mdmarkdown1.9 KB
references/simplification-patterns.mdmarkdown1.9 KB
references/simplify-ignore.mdmarkdown1.7 KB

references/simplification-patterns.md

View on GitHub
# Simplification patterns (code-simplification)

## Signal table

| Pattern | Signal | Simplification |
|---------|--------|----------------|
| Deep nesting (3+) | Hard to follow flow | Guard clauses, extract helpers |
| Long functions (50+ lines) | Multiple responsibilities | Split named functions |
| Nested ternaries | Mental stack | if/else, switch, lookup map |
| Boolean flag params | `fn(true, false)` | Options object or separate functions |
| Repeated conditionals | Same `if` in many places | Named predicate function |
| Generic names | `data`, `result`, `temp` | Domain-specific names |
| Abbreviations | `usr`, `cfg` | Full words unless universal (`id`, `url`) |
| "What" comments | `// increment` above `++` | Delete; keep "why" comments |
| Duplicated logic | Same 5+ lines twice | Shared function |
| Dead code | Unreachable, unused imports | Remove after confirming dead |
| Wrapper with no value | Pass-through only | Inline or delete |

## TypeScript / JavaScript (selected)

```typescript
// Before: unnecessary async
async function getUser(id: string) {
  return await userService.findById(id);
}
// After
function getUser(id: string) {
  return userService.findById(id);
}

// Before: manual filter loop
const active: User[] = [];
for (const u of users) if (u.isActive) active.push(u);
// After
const active = users.filter((u) => u.isActive);
```

## Python (selected)

```python
# Before: nested ifs
def process(data):
    if data is not None:
        if data.is_valid():
            return do_work(data)
# After: guard clauses
def process(data):
    if data is None:
        raise TypeError("Data is None")
    if not data.is_valid():
        raise ValueError("Invalid data")
    return do_work(data)
```

## React (judgment calls)

- Verbose conditional render → early return or small derived variables
- Prop drilling → flag for composition/context review; do not auto-refactor without user approval
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 465kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 192kUpdated Claude CodeCodexVerifiedInstall