install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/code-simplifier" ~/.claude/skills/comeonoliver-skillshub-code-simplifier-84a405 && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/code-simplifier/SKILL.mdsource content
Community Code Simplification Best Practices
Comprehensive code simplification guide for AI agents and LLMs. Contains 47 rules across 8 categories, prioritized by impact from critical (context discovery, behavior preservation) to incremental (language idioms). Each rule includes detailed explanations, real-world examples comparing incorrect vs. correct implementations, and specific impact metrics.
Core Principles
- Context First: Understand project conventions before making any changes
- Behavior Preservation: Change how code is written, never what it does
- Scope Discipline: Focus on recently modified code, keep diffs small
- Clarity Over Brevity: Explicit, readable code beats clever one-liners
When to Apply
Reference these guidelines when:
- Simplifying or cleaning up recently modified code
- Reducing nesting, complexity, or duplication
- Improving naming and readability
- Applying language-specific idiomatic patterns
- Reviewing code for maintainability issues
Rule Categories by Priority
| Priority | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | Context Discovery | CRITICAL | | 4 |
| 2 | Behavior Preservation | CRITICAL | | 6 |
| 3 | Scope Management | HIGH | | 5 |
| 4 | Control Flow Simplification | HIGH | | 9 |
| 5 | Naming and Clarity | MEDIUM-HIGH | | 6 |
| 6 | Duplication Reduction | MEDIUM | | 5 |
| 7 | Dead Code Elimination | MEDIUM | | 5 |
| 8 | Language Idioms | LOW-MEDIUM | | 7 |
Quick Reference
1. Context Discovery (CRITICAL)
- Always read CLAUDE.md before simplifyingctx-read-claude-md
- Check for linting and formatting configsctx-detect-lint-config
- Match existing code style in file and projectctx-follow-existing-patterns
- Project conventions override generic best practicesctx-project-over-generic
2. Behavior Preservation (CRITICAL)
- Preserve all return values and outputsbehave-preserve-outputs
- Preserve error messages, types, and handlingbehave-preserve-errors
- Preserve public function signatures and typesbehave-preserve-api
- Preserve side effects (logging, I/O, state changes)behave-preserve-side-effects
- Forbid subtle semantic changesbehave-no-semantics-change
- Verify behavior preservation before finalizingbehave-verify-before-commit
3. Scope Management (HIGH)
- Focus on recently modified code onlyscope-recent-code-only
- Keep changes small and reviewablescope-minimal-diff
- No unrelated refactorsscope-no-unrelated-refactors
- Avoid global rewrites and architectural changesscope-no-global-rewrites
- Respect module and component boundariesscope-respect-boundaries
4. Control Flow Simplification (HIGH)
- Use early returns to reduce nestingflow-early-return
- Use guard clauses for preconditionsflow-guard-clauses
- Never use nested ternary operatorsflow-no-nested-ternaries
- Prefer explicit control flow over dense expressionsflow-explicit-over-dense
- Flatten deep nesting to maximum 2-3 levelsflow-flatten-nesting
- Each code block should do one thingflow-single-responsibility
- Prefer positive conditions over double negativesflow-positive-conditions
- Use optional chaining and nullish coalescingflow-optional-chaining
- Simplify boolean expressionsflow-boolean-simplification
5. Naming and Clarity (MEDIUM-HIGH)
- Use intention-revealing namesname-intention-revealing
- Use nouns for data, verbs for actionsname-nouns-for-data
- Avoid cryptic abbreviationsname-avoid-abbreviations
- Use consistent vocabulary throughoutname-consistent-vocabulary
- Avoid generic namesname-avoid-generic
- Prefer string interpolation over concatenationname-string-interpolation
6. Duplication Reduction (MEDIUM)
- Apply the rule of threedup-rule-of-three
- Avoid single-use helper functionsdup-no-single-use-helpers
- Extract only when it improves claritydup-extract-for-clarity
- Prefer duplication over premature abstractiondup-avoid-over-abstraction
- Use data-driven patterns over repetitive conditionalsdup-data-driven
7. Dead Code Elimination (MEDIUM)
- Delete unused code artifactsdead-remove-unused
- Delete code, never comment it outdead-delete-not-comment
- Remove comments that state the obviousdead-remove-obvious-comments
- Keep comments that explain why, not whatdead-keep-why-comments
- Remove stale TODO/FIXME commentsdead-remove-todo-fixme
8. Language Idioms (LOW-MEDIUM)
- Use strict types over any (TypeScript)idiom-ts-strict-types
- Use const assertions and readonly (TypeScript)idiom-ts-const-assertions
- Use ? for error propagation (Rust)idiom-rust-question-mark
- Use iterator chains when clearer (Rust)idiom-rust-iterator-chains
- Use comprehensions for simple transforms (Python)idiom-python-comprehensions
- Handle errors immediately (Go)idiom-go-error-handling
- Prefer language and stdlib builtinsidiom-prefer-language-builtins
Workflow
- Discover context: Read CLAUDE.md, lint configs, examine existing patterns
- Identify scope: Focus on recently modified code unless asked to expand
- Apply transformations: Use rules in priority order (CRITICAL first)
- Verify behavior: Ensure outputs, errors, and side effects remain identical
- Keep diffs minimal: Small, focused changes that are easy to review
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |