Index of every page on this site: llms.txt
All skills
grahamcrackers avatar

/clean-code-principles

@ca83de4
Run it yourself

Clean code principles for readable, maintainable TypeScript and React codebases. Covers naming, functions, abstraction, composition, error handling, comments, and code smells. Use when writing new code, refactoring, reviewing code quality, or when the user asks about clean code, readability, or maintainability.

Use this Skill: https://skilld.dev/gh/grahamcrackers/skills/clean-code-principles

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencespattern-adapter.md

≈791 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Adapter

Adapter makes incompatible interfaces work together by wrapping one to match the other. Learn more

Category: Structural

TypeScript Example

/**
 * The Target defines the domain-specific interface used by the client code.
 */
class Target {
    public request(): string {
        return "Target: The default target's behavior.";
    }
}

/**
 * The Adaptee contains some useful behavior, but its interface is incompatible
 * with the existing client code. The Adaptee needs some adaptation before the
 * client code can use it.
 */
class Adaptee {
    public specificRequest(): string {
        return ".eetpadA eht fo roivaheb laicepS";
    }
}

/**
 * The Adapter makes the Adaptee's interface compatible with the Target's
 * interface.
 */
class Adapter extends Target {
    private adaptee: Adaptee;

    constructor(adaptee: Adaptee) {
        super();
        this.adaptee = adaptee;
    }

    public request(): string {
        const result = this.adaptee.specificRequest().split("").reverse().join("");
        return `Adapter: (TRANSLATED) ${result}`;
    }
}

/**
 * The client code supports all classes that follow the Target interface.
 */
function clientCode(target: Target) {
    console.log(target.request());
}

console.log("Client: I can work just fine with the Target objects:");
const target = new Target();
clientCode(target);

console.log("");

const adaptee = new Adaptee();
console.log("Client: The Adaptee class has a weird interface. See, I don't understand it:");
console.log(`Adaptee: ${adaptee.specificRequest()}`);

console.log("");

console.log("Client: But I can work with it via the Adapter:");
const adapter = new Adapter(adaptee);
clientCode(adapter);

Output

Client: I can work just fine with the Target objects:
Target: The default target's behavior.

Client: The Adaptee class has a weird interface. See, I don't understand it:
Adaptee: .eetpadA eht fo roivaheb laicepS

Client: But I can work with it via the Adapter:
Adapter: (TRANSLATED) Special behavior of the Adaptee.

Also Known As

Wrapper

Real-World Example

Wrapping a third-party analytics library to match your app's tracking interface, so you can swap providers without changing application code.

interface AnalyticsTracker {
    track(event: string, data: Record<string, unknown>): void;
}

// Third-party SDK with a different API
class MixpanelSDK {
    send(eventName: string, properties: object) {
        console.log(`Mixpanel: ${eventName}`, properties);
    }
}

class MixpanelAdapter implements AnalyticsTracker {
    constructor(private sdk: MixpanelSDK) {}

    track(event: string, data: Record<string, unknown>) {
        this.sdk.send(event, data);
    }
}

const tracker: AnalyticsTracker = new MixpanelAdapter(new MixpanelSDK());
tracker.track("page_view", { path: "/home" });

When NOT to Use

  • When you control both interfaces and can just refactor one to match the other
  • When the adaptation is trivial (a one-liner wrapper function is simpler)
  • When it hides too much complexity — the abstraction may leak

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning9mo4 checks · Risk SAFE
  • Gen Agent Trust Hub9mo

    This skill is a comprehensive documentation library for clean code principles and design patterns in TypeScript and React. It contains no executable code, network operations, or security risks.

  • Socket9mo

    No alerts

  • Snyk9mo

    Risk: LOW · No issues

  • Runlayer9mo

    1/25 files flagged

Signed by skilld at ca83de4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago

README badge

README badge for grahamcrackers/skills/clean-code-principles