clean-code

A collection of coding style and design principles distilled from the experience of the int 2CATLABS community.

2|Updated May 19, 2024
One-click install
npx skills add https://github.com/YanBerdin/next-portfolio --skill clean-code-yanberdin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/YanBerdin/next-portfolio/tree/main/.github/skills/clean-code
Command: npx skills add https://github.com/YanBerdin/next-portfolio --skill clean-code-yanberdin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Clean Code principles help developers write code that is easy to read, understand, and maintain over time, reducing bugs and onboarding costs.

Core Features & Use Cases

  • Meaningful Names: Use intention-revealing names; avoid ambiguous or misleading identifiers.
  • Functions: Keep functions small, focused, and free of side effects.
  • Comments: Use comments to explain intent, not to replace clear code; avoid comments for bad code.
  • Formatting: Enforce consistent layout, vertical density, and clear structure.
  • Objects and Data Structures: Prefer proper data abstraction and avoid deep, brittle chains.
  • Error Handling: Favor explicit error propagation, clear exception use, and robust handling.
  • Unit Tests: Apply testing discipline and TDD where applicable.
  • Classes: Respect SRP and readable hierarchies.
  • Smells and Heuristics: Identify rigidity, fragility, immobility, viscosity, and unnecessary complexity; refactor accordingly.
  • 🛠️ Implementation Checklist: Use the checklist to validate changes before merging.

Quick Start

Refactor a sample function in your codebase to comply with clean-code principles.

Frequently Asked Questions about clean-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is clean code and how does it improve software maintainability?

Yes, you can apply clean code principles during refactoring to identify code smells like rigidity, fragility, and immobility. It guides you to refactor legacy code by enforcing intention-revealing names, small focused functions, and proper error handling.

How do I write meaningful names and small functions for better code quality?

To write meaningful names, use intention-revealing identifiers and avoid ambiguous terms. To improve code quality, keep functions small, focused on a single task, and free of side effects, ensuring they do exactly what their names suggest.

When should I write comments versus fixing bad code?

Yes, you can apply clean code principles during refactoring to identify code smells like rigidity, fragility, and immobility. It guides you to refactor legacy code by enforcing intention-revealing names, small focused functions, and proper error handling.

How do I handle errors and exceptions cleanly in my codebase?

To write meaningful names, use intention-revealing identifiers and avoid ambiguous terms. To improve code quality, keep functions small, focused on a single task, and free of side effects, ensuring they do exactly what their names suggest.