clean-general
Skill193 starsChanged 7 months agoMITView on GitHub
Use when writing, fixing, editing, or reviewing TypeScript code quality. Enforces Clean Code's core principles—DRY, single responsibility, clear intent, no magic numbers, proper abstractions.
2 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- phanijapps/memexedited, first seen Oct 17, 2026
- ramybarsoum/claude-skillsedited, first seen Oct 13, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- phanijapps/memex★ 051% same
- ramybarsoum/claude-skills★ 047% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- boy-scoutSkill
- clean-commentsSkill
- clean-functionsSkill
- clean-generalSkill
- clean-namesSkill
- clean-testsSkill
- python-clean-codeSkill
- boy-scoutSkill
- clean-commentsSkill
- clean-functionsSkill
- clean-namesSkill
- clean-testsSkill
- typescript-clean-codeSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Every piece of knowledge has one authoritative representation.
- Distinctive: line 31
Don't be clever. Be clear.
- Distinctive: line 113
If you can extract another function, your function does more than one thing.
- Distinctive: line 127
When reviewing AI-generated code, verify:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
General Clean Code Principles
Critical Rules
G5: DRY (Don't Repeat Yourself)
Every piece of knowledge has one authoritative representation.
// Bad - duplication
const taxRate = 0.0825;
const caTotal = subtotal * 1.0825;
const nyTotal = subtotal * 1.07;
// Good - single source of truth
const TAX_RATES: Record<string, number> = { CA: 0.0825, NY: 0.07 };
function calculateTotal(subtotal: number, state: string): number {
return subtotal * (1 + TAX_RATES[state]);
}G16: No Obscured Intent
Don't be clever. Be clear.
// Bad - what does this do?
return ((x & 0x0f) << 4) | (y & 0x0f);
// Good - obvious intent
return packCoordinates(x, y);G23: Prefer Polymorphism to If/Else
// Bad - will grow forever
function calculatePay(employee: {
type: "SALARIED" | "HOURLY" | "COMMISSIONED";
salary?: number;
hours?: number;
rate?: number;
base?: number;
commission?: number;
}): number {
if (employee.type === "SALARIED") {
return employee.salary ?? 0;
} else if (employee.type === "HOURLY") {
return (employee.hours ?? 0) * (employee.rate ?? 0);
} else if (employee.type === "COMMISSIONED") {
return (employee.base ?? 0) + (employee.commission ?? 0);
}
return 0;
}
// Good - open/closed principle
interface Employee {
calculatePay(): number;
}
class SalariedEmployee implements Employee {
constructor(private readonly salary: number) {}
calculatePay(): number {
return this.salary;
}
}
class HourlyEmployee implements Employee {
constructor(
private readonly hours: number,
private readonly rate: number,
) {}
calculatePay(): number {
return this.hours * this.rate;
}
}
class CommissionedEmployee implements Employee {
constructor(
private readonly base: number,
private readonly commission: number,
) {}
calculatePay(): number {
return this.base + this.commission;
}
}G25: Replace Magic Numbers with Named Constants
// Bad
if (elapsedTime > 86400) {
// ...
}
// Good
const SECONDS_PER_DAY = 86400;
if (elapsedTime > SECONDS_PER_DAY) {
// ...
}G30: Functions Should Do One Thing
If you can extract another function, your function does more than one thing.
G36: Law of Demeter (Avoid Train Wrecks)
// Bad - reaching through multiple objects
const outputDir = context.options.scratchDir.absolutePath;
// Good - one dot
const outputDir = context.getScratchDir();Enforcement Checklist
When reviewing AI-generated code, verify:
- No duplication (G5)
- Clear intent, no magic numbers (G16, G25)
- Polymorphism over conditionals (G23)
- Functions do one thing (G30)
- No Law of Demeter violations (G36)
- Boundary conditions handled (G3)
- Dead code removed (G9)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

