Index of every page on this site: llms.txt
All skills
hardikpthv avatar

/clean-code-basic

@53afcbc
Run it yourself

Use when writing, reviewing, or refactoring code and you want it to stay clean, simple, readable, and maintainable — applying software-engineering principles like SOLID, KISS, DRY, YAGNI, single responsibility, small focused files and functions, clear naming, low coupling, and performance awareness so the project stays scalable as it grows. Especially useful when generating code with AI agents (which tend toward big files and over-engineering). Use whenever writing or changing code, or when someone says "keep the code clean," "follow best practices," "make it maintainable/scalable," "refactor this," "this function is too complex," or "apply SOLID / clean code."

Use this Skill: https://skilld.dev/gh/hardikpthv/agent-skills/clean-code-basic

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesprinciples.md

≈505 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Principles, with examples

Short, language-neutral. The point of each is the same: make the code easy to change safely.

KISS — simplest thing that works

# over-engineered
config = ConfigFactory.create(ConfigStrategy.DEFAULT).build().resolve()
# simple
config = load_config("config.yaml")

YAGNI — don't build for imagined futures

Don't add a plugin system, a generic handle(type, ...) dispatcher, or five unused options because you might need them. Add them when a real second case appears.

DRY — remove duplicated knowledge, not coincidental similarity

  • Do extract a taxFor(order) used in three places.
  • Don't merge two 3-line blocks that happen to look alike but change for different reasons — that couples unrelated things. A little duplication is cheaper than the wrong abstraction.

Single Responsibility

# does 3 things
def handle(req): validate(req); save(req); email(req)   # split callers/orchestration from steps

Each function/module has one reason to change. A User class shouldn't also format HTML and talk to the DB.

Small & focused, shallow nesting

# nested
if user:
    if user.active:
        if user.paid:
            return grant()
# guard clauses
if not user or not user.active or not user.paid:
    return deny()
return grant()

Intention-revealing names

d → daysUntilExpiry; flag → isEmailVerified; process() → chargeInvoice(). A good name kills the comment.

Low coupling / high cohesion

  • Talk through interfaces, not another module's internals.
  • Keep related things together; unrelated things apart. If module A breaks when B's internals change, they're too coupled.

Composition over inheritance

Prefer small collaborating pieces over deep class hierarchies. Inheritance for "is-a" only; otherwise compose.

The rule behind all of them

Optimize for the reader and for change. If a reasonable next person (or agent) can't quickly understand and safely modify it, simplify.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides a comprehensive set of architectural and coding best practices for AI agents to follow when generating, reviewing, or refactoring code. It is purely informational, consisting of markdown guidelines and checklists, and contains no executable code or security risks.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 53afcbc. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 5 months ago

README badge

README badge for hardikpthv/agent-skills/clean-code-basic