dvy1987/agent-loom / .agents/skills/code-simplification
code-simplification
VerifiedSimplify 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.5 KB |
| references/examples.md | markdown | 1.9 KB |
| references/simplification-patterns.md | markdown | 1.9 KB |
| references/simplify-ignore.md | markdown | 1.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
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 465k | Updated | Claude CodeCodex | Verified | Install |
| 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: 465k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 465k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |