agentleFS
NoobyGainsNoobyGains/godmode/skills/system-design/SKILL.md

system-design

Skill115 starsChanged 7 days agoMITView on GitHub

Use when choosing or changing architecture, a database, an API style, authentication, caching, queues or background jobs, file and module organisation, hosting, or any external service, or when the user asks what to use, where to deploy, how to scale, or whether to split into services.

We split this skill into the rules it gives an agent

10 rules. 0 are common, 9 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 44 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No exceptions. No workarounds.

    line 16
  2. Distinctive:

    Move off a default only for a named requirement: Write the requirement next to the deviation: "Queue, because image processing takes 40 s …

    line 39
  3. Very specific:

    Look for a reference architecture: when the system is unusual (godmode:reference-first, architecture references).

    line 43
  4. Distinctive:

    Use the database the user already runs if it fits.

    line 74
  5. Distinctive:

    Never write password hashing, session handling or token validation from scratch.

    line 97
  6. Distinctive:

    Add a cache only when all three hold: a performance problem has been measured.

    line 101
  7. Distinctive:

    Default: no cache. Every cache needs an invalidation rule written down before it ships.

    line 110
  8. Distinctive:

    Keep it proportional: a weekend project gets five lines.

    line 174
  9. Distinctive:

    Add infrastructure for speculative scale.

    line 192
  10. Distinctive:

    Write the requirement next to every deviation from a default.

    line 200

“Common” is measured: kept by at least 6 in 10 of the 44 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

System Design

Every component in an architecture is code to maintain, a bill, and a way to fail. This skill picks the simplest structure that meets a requirement the project has now, prefers what the user already runs over anything new, and records why. Complexity must be paid for by a current, named requirement; "we might need it" pays for nothing.

The Prime Directive

NO STRUCTURAL COMPLEXITY WITHOUT A CURRENT, NAMED REQUIREMENT

No exceptions. No workarounds. No shortcuts.

When to Use

Required:

  • Choosing a database, API style, auth approach, cache, queue or job runner.
  • Deciding monolith versus services, or adding a new deployable.
  • Choosing hosting, storage, email, search, payments or any managed service.
  • Organising a new project's files and modules.
  • The user asks "what should I use", "where should I host", "how do we scale", or "should we migrate to X".

Skip:

  • The user has already chosen the stack and wants it implemented: respect the choice and build (flag a serious risk once, then proceed).
  • Bug fixes and small changes inside an existing architecture.

The Protocol

  1. List the requirements and classify each. For every need (data, auth, files, jobs, real-time, email, payments, search, hosting), mark it required now (cannot launch without it), required soon (needed within the first weeks of real use, with evidence), nice to have, or speculative. Design only for the first two. Ask the user one question at a time when a classification is unclear.
  2. Inventory what the user already has. Invoke godmode:environment-awareness for the machine and project inventory: installed databases and runtimes, container tools, cloud and hosting CLIs that are logged in, running services, existing dependencies, configuration that references services. Also ask what accounts or platforms the user or their organisation already pays for. What exists and fits wins over anything new.
  3. Start from the defaults in the decision tables below. Each default is the simplest option that covers most projects.
  4. Move off a default only for a named requirement. Write the requirement next to the deviation: "Queue, because image processing takes 40 s and must not block the request." If you cannot write that sentence, keep the default.
  5. Verify every changeable fact behind the choice (a service's limits, free tier, pricing, region, runtime support) on the vendor's current page through godmode:grounding, and cite it. Hosting terms change often; never quote a price or limit from memory.
  6. Look for a reference architecture when the system is unusual (godmode:reference-first, architecture references).
  7. Present the recommendation in the format below, with an alternative and the trigger for switching, and what you deliberately left out.
  8. Record the decision as a short decision record (context, decision, consequences, sources) in the project's docs, so the reason survives the conversation.

Decision Tables

Monolith or services

SituationChoose
New project, one teamMonolith (default), organised by capability
A growing codebase where teams step on each otherModular monolith with enforced module boundaries
A component needs independent scaling or deploys now, with evidenceExtract that one component
Separate teams own separate domains with separate release cyclesServices along those team boundaries

Martin Fowler's observation: successful microservice systems almost always started as a monolith; systems built as microservices from scratch often got into serious trouble. Shopify chose a modular monolith over microservices for one of the largest Rails codebases. <!-- https://martinfowler.com/bliki/MonolithFirst.html https://shopify.engineering/deconstructing-monolith-designing-software-maximizes-developer-productivity -->

Database

RequirementChoose
Relational data, transactions, multiple users (most applications)PostgreSQL (default)
Single server or embedded, modest write concurrency, simplest operationsSQLite: one writer at a time, but writes take milliseconds; the SQLite authors say sites under 100K hits a day should work fine <!-- https://www.sqlite.org/whentouse.html -->
Some records with variable shapePostgreSQL jsonb columns before a document database <!-- https://www.postgresql.org/docs/current/datatype-json.html -->
Text search over application dataPostgreSQL full-text search before a search engine <!-- https://www.postgresql.org/docs/current/textsearch.html -->
Cache, sessions, rate-limit counters, ephemeral dataRedis or a compatible store, only once needed
Search relevance, facets and scale beyond the databaseA dedicated search engine
Time-series, graph or analytics workloads that dominate the productA specialised store, chosen with evidence

Use the database the user already runs if it fits. One database until a second access pattern clearly needs its own store.

API style

ContextChoose
CRUD, public or partner API, browser clientsREST with JSON (default); design details from godmode:reference-first
Many client shapes over nested data, client-controlled queriesGraphQL
Internal service-to-service calls with measured throughput needs, streaminggRPC
Server pushes to the browserServer-sent events for one-way streams; WebSockets for two-way <!-- https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events -->
Notifying other systems of eventsSigned webhooks (Standard Webhooks)

A full-stack framework's built-in server functions are fine for its own front end; add a separate API only when another client needs it.

Authentication

ContextChoose
A web app with its own users on one siteServer-side sessions in secure, HttpOnly cookies (default), via the framework's established auth library <!-- https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html -->
Social or enterprise sign-inOAuth 2.0 / OpenID Connect through a maintained library or provider
A separate API used by third parties or other originsShort-lived access tokens with refresh, or API keys for server-to-server
Polished hosted UI, organisations and SSO wanted quicklyA managed identity provider, if the user accepts the cost and lock-in

Never write password hashing, session handling or token validation from scratch. Stateless tokens cannot be revoked before expiry without extra machinery; sessions can. Security review goes to godmode:security-protocol (and the OWASP Authentication Cheat Sheet). <!-- https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html -->

Caching

Add a cache only when all three hold: a performance problem has been measured; the query or code cannot simply be fixed; the data is read far more than it is written and can be slightly stale.

LayerWhen
HTTP caching and a CDNStatic assets and public pages (first and cheapest)
In-process memoryOne instance, small data
Shared cache (Redis or compatible)Several instances need the same cached data
Materialised viewsExpensive aggregations in the database

Default: no cache. Every cache needs an invalidation rule written down before it ships.

Queues and background jobs

NeedChoose
Work fits in the requestDirect call (default)
Occasional slow work, retries, already on PostgreSQLA Postgres-backed job queue (for example pg-boss for Node.js) <!-- https://github.com/timgit/pg-boss -->
Many jobs, Redis already presentA Redis-backed queue (BullMQ for Node.js, Celery for Python) <!-- https://docs.bullmq.io https://docs.celeryq.dev -->
Multi-step workflows that must resume after failure, serverless hostingA durable-workflow service (for example Inngest, which retries from the failed step) <!-- https://www.inngest.com/docs -->
Event streaming with replay, many consumers, high volumeA log-based broker such as Kafka, with evidence of the volume
Scheduled tasksThe host's cron or scheduler first

Hosting and services

Choose by what the user already uses, then by the shape of the workload. The comparison, with links to each vendor's current limits and pricing pages, is in hosting-and-services.md. Rules:

  • Already deploying somewhere that fits: stay there.
  • Framework with a first-party host and the user is happy with it: that host is the default.
  • Steady traffic, containers, full control wanted: a VPS or container platform.
  • Spiky or low traffic, static-heavy: static hosting plus serverless functions.
  • One provider that covers database, auth and storage beats three providers glued together, if it fits.

File Organisation

Organise by capability, not by technical layer, so one change touches one directory:

src/
  billing/
    billing.routes.ts
    billing.service.ts
    billing.repository.ts
    billing.test.ts
  accounts/
    ...
  shared/
    db.ts
    auth.middleware.ts
    logger.ts

In an existing project, follow its layout (godmode:codebase-conventions), even if it is by layer. For a new project, set it up with godmode:project-bootstrap.

Presenting the Recommendation

Requirements
- <need>: required now / required soon / nice to have (deferred) / speculative (dropped)

Already available
- <databases, runtimes, CLIs, accounts found>

Recommended
| Layer | Choice | Why (requirement, and what the user already has) | Source |
Expected running cost: <from the vendor's current pricing page, dated>, or "free tier covers current scale" with the limit cited.

Alternative and when to switch
| Layer | Alternative | Switch when <measurable trigger> |

Deliberately not used
- <service or pattern>: <why it is not needed now>

Keep it proportional: a weekend project gets five lines.

Cognitive Traps

RationalisationTruth
"We might need microservices later."Extracting later is possible; merging a premature split is painful. Start with a monolith.
"NoSQL is more flexible."PostgreSQL stores JSON. Flexibility without a schema usually becomes confusion.
"Everyone uses X now."Popularity is not a requirement. What does this project need, and what does the user already run?
"JWTs are more secure."They are harder to revoke. Sessions are simpler for a single site.
"We need a cache for speed."Measure first. Most slowness is a query or an N+1, not a missing cache.
"A queue makes it scalable."A queue adds a moving part. Use one when work cannot fit in the request.
"Serverless is always cheaper."It depends on the traffic shape. Check the current pricing for this workload.
"I remember the free tier."Free tiers and limits change. Read the vendor page today and cite it.

Guardrails

Never:

  • Add infrastructure for speculative scale.
  • Recommend a new service without first checking what the user already has.
  • Quote a price, limit or free tier without a current source.
  • Stack several managed services where one that the user already uses would do.
  • Override a stack the user has chosen; state the risk once and build.

Always:

  • Classify every requirement before choosing.
  • Write the requirement next to every deviation from a default.
  • Give an alternative with a measurable switch trigger.
  • Say what you left out and why.
  • Record the decision with its sources.

Connections

  • godmode:environment-awareness: supplies the inventory of what the user already runs; always first for hosting and service choices.
  • godmode:rationale: questions whether the feature needs building at all, before this skill decides how.
  • godmode:reference-first: reference architectures and API, schema and CI references.
  • godmode:grounding: verifies vendor limits, pricing and capabilities.
  • godmode:security-protocol: reviews auth, data flow and secrets handling.
  • godmode:performance-tuning: measures before any cache or scaling change.
  • godmode:project-bootstrap: sets up the chosen structure in a new repository.

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.

Reviews can't be read right now.

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.