clean-code

Enforces clean-code standards for writing, refactoring, and reviewing code in any language.

553|70|Updated Feb 28, 2023
One-click install
npx skills add https://github.com/operately/operately --skill clean-code-operately
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/operately/operately/tree/main/.agents/skills/clean-code
Command: npx skills add https://github.com/operately/operately --skill clean-code-operately

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Codebases degrade over time through unclear naming, oversized methods, hidden side effects, duplication, and untested changes. This Skill gives an AI coding assistant a mandatory, language-agnostic engineering contract so every piece of code it writes, changes, or reviews meets consistent readability, testability, and maintainability standards. ## Core Features & Use Cases - Sixteen enforceable rules: Covers naming, small focused methods, abstraction-level separation, explicit side effects, guard clauses, error handling as design, cohesion, duplication removal, test-first development, and continuous refactoring. - Test-driven workflow: Requires a failing test before behavior changes or bug fixes, with regression coverage and readable, deterministic tests named by expected outcome. - Ecosystem-specific guidance: Includes detailed rules for Ecto queries (prefer assoc joins, recursive CTEs over N+1 Elixir recursion, Ecto DSL over raw SQL), Operately API enum/serializer modeling, and the Operately.Repo.Getter requester-aware loading pattern. - Use Case: Ask the assistant to refactor a tangled Elixir context module; it will extract intention-revealing functions, replace manual joins with assoc, convert per-step hierarchy queries into a recursive CTE, and add failing tests first. ## Quick Start Ask the assistant to refactor the attached module following clean-code principles and add tests for the changed behavior.

Frequently Asked Questions about clean-code

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

FAQPage Schema
How do I enforce clean code principles with an AI coding assistant?▼

Activate this Skill and the assistant applies sixteen mandatory rules covering naming, small methods, guard clauses, explicit side effects, and test-first development. Every change must leave the touched code cleaner than before, with passing tests.

How to write recursive hierarchy queries in Ecto without N+1 problems?▼

Use a recursive CTE: define an anchor query, a recursive step joined with union_all, then attach it with recursive_ctes(true) and with_cte. This walks trees in one database query instead of recursive Elixir calls that hit the database per iteration.

Does this Skill work with languages other than Elixir?▼

Yes, the core rules are language-agnostic and adapt to each language's idioms, such as boolean naming conventions like active? or isActive. Only rules 14 and 15 are specific to Ecto queries and the Operately API stack.

When should I use assoc joins versus manual on conditions in Ecto?▼

Prefer join with assoc when a schema association already expresses the relationship, keeping foreign keys consistent. Use manual on conditions only when joining CTEs, string table names, or when the join condition goes beyond the association.

What are the limitations of test-first development in legacy code?▼

When strict test-first is blocked by missing harnesses or legacy constraints, the Skill requires stating so explicitly, adding the nearest useful coverage immediately, and leaving the area more testable than before rather than skipping tests entirely.