sfermanelli-clean-code

Clean up TypeScript/JavaScript naming, structure, formatting while preserving behavior.

1|Updated Mar 19, 2026
One-click install
npx skills add https://github.com/sebafermanelli/sfermanelli-skills --skill sfermanelli-clean-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sfermanelli-clean-code
Source: https://github.com/sebafermanelli/sfermanelli-skills/tree/main/sfermanelli-clean-code
Command: npx skills add https://github.com/sebafermanelli/sfermanelli-skills --skill sfermanelli-clean-code

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Messy, inconsistent code makes maintenance costly and onboarding slow. This Skill guides you to improve readability and maintainability without altering behavior.

Core Features & Use Cases

  • Meaningful Names: enforce intention-revealing identifiers and avoid misleading names.
  • Functions: keep functions short, do one thing, and apply guard clauses to flatten logic.
  • TypeScript-Specific Clean Patterns: use readonly where appropriate, narrow types, and prefer discriminated unions.
  • Comments: explain why, not what, and remove redundant commentary.
  • Formatting: organize imports, structure code for the "newspaper" flow, and align sections.
  • The Law of Demeter: minimize chained access and encourage telling objects to do the work.

Quick Start

Run a guided clean-up pass on a TypeScript file to improve naming, structure, and comments while preserving behavior.

Frequently Asked Questions about sfermanelli-clean-code

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

FAQPage Schema
How do I refactor TypeScript code to improve readability and maintainability?

Refactor TypeScript for readability by enforcing intention-revealing names, short single-purpose functions, guard clauses, and organized formatting without altering runtime behavior. This process cleans up structure and documentation to make onboarding and code reviews significantly easier.

What are guard clauses and how do they flatten logic in JavaScript projects?

Guard clauses flatten logic by checking preconditions early and returning immediately, avoiding deep nested conditional blocks. Applying them in JavaScript keeps functions short, ensures code does one thing, and aligns with the newspaper metaphor for top-down code flow.

Can I use this clean code approach for large TypeScript codebases?

Yes, this approach suits TypeScript projects of varying sizes, including large codebases. It handles ongoing refactoring efforts by enforcing consistent naming conventions, readonly patterns, discriminated unions, and formatting rules across the entire project.

What is the best way to write meaningful names and comments in TypeScript?

Write meaningful names by using intention-revealing identifiers and avoiding misleading terms. Write comments to explain why the code exists rather than what it does, removing redundant commentary that merely restates the implementation logic.

Does this refactoring method change the behavior of existing JavaScript functions?

No, this refactoring method strictly preserves existing behavior. It focuses on improving code structure, formatting, and naming without altering functional logic, allowing you to clean up code safely during onboarding or routine reviews.