clean-code-principles

Enforce clean code principles when writing or reviewing code. Use when writing new functions, refactoring existing code, or reviewing code for readability and maintainability. Covers guard clauses, modularization, naming conventions, and more.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "clean-code-principles" with this command: npx skills add aj-comp/agent-skills/aj-comp-agent-skills-clean-code-principles

Clean Code Principles

A collection of principles and patterns for writing clean, readable, and maintainable code.

When to Use This Skill

  • Writing new functions or methods
  • Refactoring nested or complex code
  • Reviewing code for readability
  • Discussing code quality improvements

Note: The principles and rules in each document apply to all programming languages. Examples are shown in a specific language for concreteness, but the patterns themselves are language-agnostic.

Important: When refactoring, remove comments that are no longer relevant to the changed code. However, comments that are still valid and provide useful context (e.g., why a decision was made, business rules, workarounds, warnings) must be preserved.

Principles Overview

PrincipleDescriptionReference
Guard Clause PatternFail fast with early returns, keep code flatguard-clause-pattern.md
Function DecompositionBreak large functions into small, focused unitsfunction-decomposition.md
Magic Numbers & StringsReplace unexplained literals with named constants or enumsmagic-numbers-and-strings.md
DRY PrincipleEliminate duplicated logic with shared abstractionsdry-principle.md
Conditional SimplificationReduce complex branching into clear, readable conditionsconditional-simplification.md
Boolean & Flag ParametersReplace boolean params with enums, methods, or option objectsboolean-and-flag-parameters.md

Core Philosophy

  1. Readability First — Code is read far more often than it is written
  2. Fail Fast — Handle errors and edge cases early, keep the happy path clear
  3. Single Responsibility — Each function/class should do one thing well
  4. Minimal Nesting — Flat code is easier to follow than deeply nested code
  5. Meaningful Names — Names should reveal intent without needing comments
  6. DRY, but not at the cost of clarity — Avoid premature abstraction

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

clean-code-principles

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

Repository Source
213.4K23Kvercel
Coding

svelte5-best-practices

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

apify-actor-development

No summary provided by upstream source.

Repository SourceNeeds Review
2.1K-apify