agentleFS
e-reitbauere-reitbauer/habits/skills/patterns/SKILL.md

patterns

Skill1 starsChanged 6 days agoMITView on GitHub

Use when structuring or restructuring code: designing a feature or module, refactoring, choosing an architecture or layering, deciding between patterns (repository, strategy, factory, observer, state machine, dependency injection), or when asked "how should I structure this?" or "is this a good design?".

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use setup.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • VercelSkill

    setup

    Set up Vercel CLI and project configuration. Use when the user says "set up Vercel", "configure Vercel", "link to Vercel", or "vercel init".

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 5

    Distinctive

    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
  1. Distinctive:

    Read how the codebase already solves this kind of problem, and follow it unless it's the problem.

    line 15
  2. Distinctive:

    Start from the simplest code that works: functions and data.

    line 16
  3. Distinctive:

    Prefer composition over inheritance, and small interfaces owned by their consumer.

    line 17
  4. Distinctive:

    Keep side effects (IO, time, randomness) at the edges and pass their results in, so the core stays pure and testable.

    line 25
  5. Distinctive:

    Keep state as local as possible.

    line 42

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Design patterns

Patterns are answers to specific pressures. Name the pressure first; if it isn't there, the plain version is the right design. Recommend, explain the tradeoff in a sentence, and match what the codebase already does.

How to decide

  1. Read how the codebase already solves this kind of problem, and follow it unless it's the problem.
  2. Start from the simplest code that works: functions and data. Add structure only for a pressure you can point to: a second implementation that exists now, a test that can't be written, a change that keeps touching the same five files.
  3. Prefer composition over inheritance, and small interfaces owned by their consumer.
  4. Say what the design costs: indirection, files, concepts to learn.

Architecture

  • Layers: presentation (UI, controllers) → domain/application (use cases, rules) → data (repositories, clients). Dependencies point inward; the domain imports nothing from the outer layers.
  • Organize by feature (auth/, tags/) before organizing by layer, once a project has more than a handful of features.
  • Dependency injection through constructors. A DI framework only when the project already uses one or the wiring has outgrown a composition root.
  • Keep side effects (IO, time, randomness) at the edges and pass their results in, so the core stays pure and testable.

Patterns worth knowing, and their signal

PatternUse whenNot when
Repositorydata access must be swappable or faked, or several sources (cache + network) sit behind one source of truthone simple query used in one place
Strategyseveral interchangeable algorithms chosen at runtimethere's one algorithm and a hypothetical second one
Factoryconstruction is complex, conditional, or must hide the concrete typea constructor call says it all
Adapterwrapping a third-party API so its types don't leak into your codethe API is already yours
Observer / streamsmany consumers react to changes (Flow, Combine, signals, events)one caller can just call a function
State machinean object moves through states with rules about transitions (auth, connections, game sessions)two booleans would do, and will stay two
Result / sealed outcomescallers must handle distinct failure casesthe failure is a bug and should throw
Buildermany optional parameters in a language without named or default argumentsKotlin, Swift, TypeScript: use named/default parameters

Frontend state

  • Keep state as local as possible; lift it only to the nearest common owner.
  • Server state (fetched data) is a cache, not app state: use the framework's query/cache layer rather than copying it into a store.
  • One source of truth per piece of state, with derived values computed, not stored.

API design

  • Model the domain, not the database. Resource-oriented REST with consistent naming, or RPC when operations don't map to resources.
  • Version the contract explicitly once there are external consumers; never break a published shape silently.
  • Validate at the boundary, return typed errors with stable codes, and paginate every list.

Red flags to call out

God classes and "Manager"/"Helper" grab-bags, interfaces with exactly one implementation and no test seam, inheritance deeper than two levels, singletons holding mutable state, abstractions named for patterns instead of the domain (AbstractFactoryProvider), and speculative generality.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.