agentleFS
GuillemRocaGuillemRoca/agent-skills-android/skills/code-simplification/SKILL.md

code-simplification

Skill2 starsChanged 40 days agoMITView on GitHub

Use when code is harder to understand than it needs to be. Guides incremental simplification that preserves behavior exactly, following project conventions and Kotlin idioms.

83 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use architecture-decision-records, ci-cd and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GSA-TTSSkill

    architecture-decision-records

    Load when a user wants architecture decision records (ADRs) drafted from requirements or a design discussion, asks which decisions need an ADR, or wants an ADR draft reviewed for one-sided trade-offs, weak alternatives or missing requirement links. Not for setting up a project's whole documentation system (project-documentation-system).

    Also in 4 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 3 projects that use this

  • OpenAISkill

    security-best-practices

    Perform language and framework specific security best-practice reviews and suggest improvements. Trigger only when the user explicitly requests security best practices guidance, a security review/report, or secure-by-default coding help. Trigger only for supported languages (python, javascript/typescript, go). Do not trigger for general code review, debugging, or non-security tasks.

    Also in 3 projects that use this

  • GitHubSkill

    conventional-commit

    Prompt and workflow for generating conventional commit messages using a structured XML format. Guides users to create standardized, descriptive commit messages in line with the Conventional Commits specification, including instructions, examples, and validation.

    Also in 3 projects that use this

  • silvainfmSkill

    marketing-ideas

    When the user needs marketing ideas, inspiration, or strategies for their SaaS or software product. Also use when the user asks for 'marketing ideas,' 'growth ideas,' 'how to market,' 'marketing strategies,' 'marketing tactics,' 'ways to promote,' or 'ideas to grow.' This skill provides 140 proven marketing approaches organized by category.

    Also in 4 projects that use this

  • IgorGanapolskySkill

    graphify

    Query the local Graphify-Labs AST knowledge graph for ThumbGate architecture questions (what connects X to Y, explain a symbol, PreToolUse/gates/adapters). Slash: /graphify.

    Also in 5 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 77 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After a feature is working and tested (simplify, don't rewrite)

    line 19
  2. Very specific:

    Run ./gradlew test — verify tests pass

    line 66
  3. Distinctive:

    If tests fail, revert immediately and investigate

    line 67

“Common” is measured: kept by at least 6 in 10 of the 77 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Simplification

Overview

Simplicity is about comprehension speed, not line count. Simple code is code another developer can read and understand quickly. This skill guides incremental simplification — making code easier to understand without changing what it does.

When to Use

  • Code is harder to understand than its logic warrants
  • Functions exceed ~40 lines or have deep nesting
  • After a feature is working and tested (simplify, don't rewrite)
  • During code review when readability is flagged

Don't simplify when:

  • Code is already clean and conventional
  • You don't fully understand what the code does (Chesterton's Fence)
  • The code is performance-critical and structured for speed
  • A rewrite is already planned

Core Principles

  1. Preserve Behavior Exactly — simplification changes form, not function
  2. Follow Project Conventions — match existing patterns, don't introduce new styles
  3. Prefer Clarity Over Cleverness — readable beats concise
  4. Maintain Balance — don't over-abstract or under-abstract
  5. Scope Appropriately — simplify what was asked, nothing more

Core Process

Step 1: Understand (Chesterton's Fence)

  1. Read the code and its tests — understand what it does and why
  2. Check git blame — understand the history of complex sections
  3. Identify the author's intent — is complexity intentional (performance, platform workaround)?
  4. Respect /* simplify-ignore-start */ blocks — skip annotated sections

Step 2: Identify Opportunities

  1. Scan for these patterns:
PatternKotlin Simplification
Deep nestingEarly returns / when expressions
Long functionsExtract well-named private functions
Complex conditionalswhen expression or sealed class
Nullable chains?.let { }, ?:, safe calls
Manual null checksrequireNotNull(), checkNotNull()
Mutable stateval over var, immutable collections
Callback nestingCoroutines / Flow
Builder patternsKotlin DSL or apply/also
Type casting chainsis smart casts, sealed hierarchies
Manual resource managementuse { } or withContext

Step 3: Apply Incrementally

  1. One change at a time:
    • Make a single simplification
    • Run ./gradlew test — verify tests pass
    • If tests fail, revert immediately and investigate
    • Commit the change
    • Repeat
  2. Common Kotlin simplifications:
// Before: nested null checks
fun getDisplayName(user: User?): String {
    if (user != null) {
        if (user.displayName != null) {
            return user.displayName
        } else {
            return user.email
        }
    } else {
        return "Anonymous"
    }
}

// After: idiomatic Kotlin
fun getDisplayName(user: User?): String =
    user?.displayName ?: user?.email ?: "Anonymous"
// Before: when with boolean conditions
fun categorize(score: Int): String {
    if (score >= 90) return "Excellent"
    else if (score >= 70) return "Good"
    else if (score >= 50) return "Average"
    else return "Poor"
}

// After: when expression
fun categorize(score: Int): String = when {
    score >= 90 -> "Excellent"
    score >= 70 -> "Good"
    score >= 50 -> "Average"
    else -> "Poor"
}

Step 4: Verify

  1. Run the full check:
    • ./gradlew test — all tests pass
    • ./gradlew lint — no new warnings
    • ./gradlew assembleDebug — builds successfully
  2. Review the diff — does it only change form, not behavior?
  3. Read the simplified code fresh — is it actually clearer?

Common Rationalizations

ShortcutWhy It Fails
"I'll simplify and add features at the same time"Mixed changes are impossible to review and risky to revert.
"This clever one-liner is simpler"If it takes 30 seconds to parse, it's not simpler.
"I'll refactor the whole file while I'm here"Scope creep. Simplify what was asked, nothing more.
"The tests are passing, so my refactor is safe"Tests may not cover the behavior you changed. Check coverage first.

Red Flags

  • Behavior changed during "simplification"
  • Tests skipped or disabled
  • Simplification mixed with feature changes
  • New abstractions introduced for single-use code
  • Code made "shorter" but harder to read
  • /* simplify-ignore */ blocks modified

Verification

  • All existing tests pass (./gradlew test)
  • Build succeeds (./gradlew assembleDebug)
  • No lint regressions (./gradlew lint)
  • Diff changes form only — not behavior
  • Each simplification committed separately
  • Code is genuinely easier to understand (not just shorter)
  • /* simplify-ignore */ blocks untouched

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.