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.

SKILL.md

≈172 tokens for metadata: the name and description. ≈961 when used: this file. ≈969 more on demand in 2 files.

Description uses 8.6% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈688 characters, or 8.6%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Clean Code (Basic)

Keep code simple, readable, and maintainable as it's written — so the project scales instead of rotting. This matters most when code is generated fast (by agents): the default failure mode is big files, deep functions, and premature abstraction. This skill is the guardrail.

When to use

  • While writing or changing code in any language
  • "Keep it clean / maintainable / scalable" · "refactor this" · "this is too complex"
  • Applying SOLID / KISS / DRY / YAGNI or a clean-code review

Not for: bug hunting (that's debugging), security review (see web-security-audit), or style-only formatting (use a linter/formatter).

The core principles

  • KISS — the simplest thing that works. Prefer boring, obvious code over clever code.
  • YAGNI — build for today's requirement, not an imagined future. Delete speculative flexibility.
  • DRY (but not prematurely) — remove real duplication of knowledge; don't abstract two lines that merely look alike. A little duplication beats the wrong abstraction.
  • Single Responsibility — each function, file, and module does one thing and has one reason to change.
  • Small & focused — functions do one thing and stay short; files stay focused (split when they grow large or mix concerns); keep parameter lists short.
  • Intention-revealing names — activeUsers not au; a good name removes the need for a comment.
  • Low coupling, high cohesion — modules depend on little and expose clear interfaces; related things live together.
  • Readability first — code is read far more than written. Optimize for the next person (or agent).
  • Composition over inheritance; separation of concerns.

SOLID in one line each

  • S — Single Responsibility: one reason to change.
  • O — Open/Closed: open to extension, closed to modification (add, don't rewrite).
  • L — Liskov Substitution: subtypes must be usable wherever the base type is.
  • I — Interface Segregation: many small interfaces beat one fat one.
  • D — Dependency Inversion: depend on abstractions, not concrete details.

Size & shape heuristics (guidelines, not laws)

  • Functions: do one thing; if you need "and" to describe it, split it. Prefer early returns/guard clauses over deep nesting (aim to keep nesting shallow).
  • Files: one clear purpose; when a file grows large or juggles several responsibilities, that's the signal to split it.
  • Parameters: few; if many, pass an object or rethink the design.
  • No magic numbers/strings — name them.

Performance & scalability (aware, not premature)

  • Avoid obvious inefficiencies: N+1 queries, work repeated inside loops, loading everything into memory, O(n²) on hot paths. Know the big-O of the hot path.
  • Don't prematurely optimize — measure before micro-tuning; clarity first.
  • Design for growth where it actually matters: pagination, statelessness, caching at real bottlenecks, indexing queries.

Self-check before finishing

  • Does each unit do one thing? Clear, honest names?
  • Anything too big or too nested? Split/flatten it.
  • Real duplication removed — without over-abstracting?
  • Is this the simplest approach, or am I gold-plating (YAGNI)?
  • Is it testable (small units, injected dependencies)?
  • Any obvious performance trap on a hot path?

Common anti-patterns

  • God object / god function doing everything.
  • Deep nesting (arrow code) instead of guard clauses.
  • Premature abstraction / speculative generality.
  • Clever one-liners that need a comment to understand.
  • Copy-paste instead of a shared function.
  • Tight coupling — reaching into another module's internals.
  • Huge files the agent keeps appending to instead of splitting.

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