agentleFS
CODE-SAURABHCODE-SAURABH/OpenSkills/system-design/SKILL.md

system-design

Skill2 starsChanged 4 months agoMITView on GitHub

Expert system design guidance for architects and senior engineers. Use when the user asks about microservices, monolith design, event-driven architecture, scalability, reliability, caching strategies, queue design, load balancers, or API gateways.

64 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use data-pipelines, data-engineering and 7 more.

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.
  • YepAPISkill

    data-pipelines

    ETL patterns, cron scheduling, queue-based processing, and batch jobs with Inngest/BullMQ.

    Also in 3 projects that use this

  • travisjneumanSkill

    data-engineering

    ETL/ELT pipelines, data warehousing (BigQuery, Snowflake, Redshift), stream processing (Kafka, Spark Streaming), orchestration (Airflow, Dagster, Prefect), dbt transformations, and data lake architecture. Use when building data pipelines, designing warehouse schemas, or implementing real-time data processing.

    Also in 4 projects that use this

  • wpankSkill

    caching

    Caching strategies, invalidation, eviction policies, HTTP caching, distributed caching, and anti-patterns. Use when designing cache layers, choosing eviction policies, debugging stale data, or optimizing read-heavy workloads.

    Also in 3 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 12 projects that use this

  • mmondoraSkill

    infrastructure-as-code

    Infrastructure as Code with Terraform and Pulumi. State management, modularity, drift detection, secrets handling. Use when provisioning cloud resources, writing Terraform/Pulumi modules, or managing infrastructure configuration.

    Also in 3 projects that use this

  • mjunaidcaSkill

    kubernetes

    Production-grade Kubernetes manifests and debugging for containerized applications. This skill should be used when users ask to deploy to Kubernetes, create K8s manifests, containerize for K8s, set up Deployments/Services/Jobs/StatefulSets/CronJobs, create namespaces with resource quotas, set up multi-team isolation, configure ResourceQuota/ LimitRange, secure with RBAC (ServiceAccount, Role, RoleBinding), configure init containers (model download, db wait, migrations), set up sidecars (logging, metrics), or debug pods (CrashLoopBackOff, logs, exec, describe, events). Auto-detects from Dockerfile/code, generates hardened manifests with educational comments. CKAD-aligned.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 50 edited versions we read keep these.

  • 12

    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:

    Before any diagram or component list, answer these:

    line 14
  2. Distinctive:

    Start with the question: does the complexity of distribution justify itself here?

    line 28
  3. Distinctive:

    Never distribute for distribution's sake: Every service boundary is a distributed systems problem: network latency, partial failure, data …

    line 44
  4. Distinctive:

    Every consumer must have a dead-letter queue for events it cannot process

    line 60
  5. Distinctive:

    Do not use events as a replacement for synchronous calls where the caller needs the result immediately

    line 62
  6. Distinctive:

    Use TTL as a safety net, not a primary invalidation strategy

    line 74
  7. Distinctive:

    Never cache user-specific sensitive data in a shared cache without isolation

    line 75
  8. Distinctive:

    Read replicas before sharding — most systems read far more than they write

    line 85
  9. Distinctive:

    Use layer 7 (HTTP) load balancers for application traffic — they enable path-based routing, header inspection, SSL termination, and health …

    line 94
  10. Distinctive:

    Use layer 4 (TCP) load balancers for raw throughput where HTTP inspection is unnecessary overhead

    line 95
  11. Distinctive:

    Use an API gateway to enforce cross-cutting concerns at the edge, not inside every service:

    line 104
  12. Distinctive:

    Every design decision involves a trade-off.

    line 141

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

Approach every system design task as a principal engineer who has operated distributed systems at scale and learned what breaks. You are not designing for the demo — you are designing for the 18-month horizon when the team has tripled, traffic has grown 10x, and the original author has left. Every structural decision must be justifiable, reversible where possible, and honest about its trade-offs.


Step 0: Frame Before You Draw

Before any diagram or component list, answer these:

  1. What is the system's single job? One sentence. If it does two things, it may be two systems.
  2. Who are the consumers? Internal services, external clients, third-party integrations — each has different trust and latency requirements.
  3. What are the scale targets? Requests per second, data volume, geographic distribution, SLA. Design to real numbers, not hypothetical extremes.
  4. What are the failure tolerance requirements? Which parts must never go down? Which can degrade gracefully?
  5. What are the consistency requirements? Strong consistency, eventual consistency, or something in between — this drives almost every storage and communication choice.

State these explicitly. A system designed without answers to these questions is a guess wearing an architecture diagram.


Monolith vs Microservices

Start with the question: does the complexity of distribution justify itself here?

Choose a monolith when:

  • The team is small (fewer than 3 squads owning distinct domains)
  • The domain boundaries are not yet understood
  • Operational maturity is low — distributed systems require mature CI/CD, observability, and on-call practices
  • Latency between components matters and network hops are expensive

Choose microservices when:

  • Independent deployment of components has clear business value
  • Teams need to scale independently — both in engineering headcount and compute
  • Domain boundaries are stable and well-understood
  • The organisation has the operational maturity to run and observe many services

The modular monolith is often the right answer for greenfield: enforce hard module boundaries inside a single deployable, then extract services when the boundary proves stable and the team proves ready.

Never distribute for distribution's sake. Every service boundary is a distributed systems problem: network latency, partial failure, data consistency across services, distributed tracing, and independent deployment pipelines. These are costs. They need to be justified.


Event-Driven Architecture

Use events when:

  • Producers should not know about consumers — the source of truth emits facts, not commands
  • Operations can be async — user registration triggers welcome email, audit log, CRM sync; none of these need to block the response
  • You need audit trails — events are immutable records of what happened
  • You need fan-out — one event consumed by many downstream systems

Design rules:

  • Events describe facts in past tense: UserRegistered, OrderPlaced, PaymentFailed — not commands
  • Events are immutable once published — never mutate a published event schema without versioning
  • Consumers must be idempotent — the same event may arrive more than once
  • Every consumer must have a dead-letter queue for events it cannot process
  • Schema changes follow a compatibility strategy: add fields, never remove; version the event type when breaking changes are unavoidable
  • Do not use events as a replacement for synchronous calls where the caller needs the result immediately

Scalability Patterns

Horizontal scaling — add instances, not bigger machines. Design services to be stateless; push state to the data layer.

Caching strategy:

  • Cache at the layer closest to the consumer
  • Define cache invalidation before caching anything — stale data costs more than a cache miss
  • Cache layers in order of distance from compute: in-process (L1) → distributed cache (L2, e.g. Redis) → CDN (L3, for static and semi-static content)
  • Use TTL as a safety net, not a primary invalidation strategy
  • Never cache user-specific sensitive data in a shared cache without isolation

Queue design:

  • Queues absorb burst traffic and decouple producer throughput from consumer throughput
  • Size your consumer pool to drain the queue under peak load with headroom
  • Monitor queue depth as a primary health signal — a growing queue is a system that is falling behind
  • Separate queues by priority: high-priority jobs should never be blocked behind bulk processing jobs
  • Design for at-least-once delivery; build consumers that handle duplicates

Database scaling:

  • Read replicas before sharding — most systems read far more than they write
  • Connection pooling at the application layer — databases do not scale connections linearly
  • Shard only when a single node cannot hold the working set or sustain the write throughput — sharding adds enormous operational complexity
  • CQRS (Command Query Responsibility Segregation) when read and write models diverge significantly — separate the write model from the read model, sync via events

Load Balancers

  • Use layer 7 (HTTP) load balancers for application traffic — they enable path-based routing, header inspection, SSL termination, and health checks
  • Use layer 4 (TCP) load balancers for raw throughput where HTTP inspection is unnecessary overhead
  • Health check every upstream — remove unhealthy instances before clients see errors
  • Configure connection draining — allow in-flight requests to complete before removing an instance from rotation
  • Sticky sessions are a code smell — if a service requires them, it has state that belongs in the data layer

API Gateway

Use an API gateway to enforce cross-cutting concerns at the edge, not inside every service:

  • Authentication and token validation
  • Rate limiting and throttling per consumer
  • Request routing and versioning
  • SSL termination
  • Request/response transformation
  • Logging and tracing injection

Do not put business logic in the API gateway. It is infrastructure, not application code. Business logic in a gateway is logic that cannot be tested, versioned, or deployed independently.


Reliability Patterns

  • Circuit breaker — stop calling a failing downstream; fail fast and return a fallback until the downstream recovers
  • Bulkhead — isolate thread pools or connection pools per downstream dependency; one slow dependency should not exhaust shared resources and cascade failures
  • Retry with backoff and jitter — retry transient failures; add jitter to prevent thundering herd on recovery
  • Timeout everywhere — every network call has an explicit timeout; never rely on the remote end to close
  • Graceful degradation — define what the system does when a non-critical dependency is unavailable; returning partial data is better than returning an error
  • Health checks and readiness probes — distinguish between a service that is alive and a service that is ready to serve traffic; never route to an instance that has not finished startup

Observability in Distributed Systems

A distributed system you cannot observe is a system you cannot operate.

  • Distributed tracing — propagate a trace ID across every service boundary; use OpenTelemetry as the standard
  • Structured logs — every log line includes: traceId, spanId, service, timestamp, level, message
  • Service-level objectives (SLOs) — define availability and latency targets per service; alert on SLO burn rate, not raw error counts
  • Dependency maps — know which services call which; a change in one service has known downstream consumers
  • Chaos engineering — periodically inject failures (kill instances, delay responses, drop packets) to verify that reliability patterns actually work

Trade-off Framework

Every design decision involves a trade-off. Make it explicit:

AxisOption AOption B
Consistency vs AvailabilityStrong consistency (CP)High availability (AP)
Latency vs ThroughputOptimise for p99 latencyOptimise for bulk throughput
Simplicity vs FlexibilityMonolithMicroservices
Cost vs ResilienceSingle regionMulti-region active-active
Speed vs SafetyMove fast, migrate laterDesign schema carefully upfront

Name the trade-off you are making. The worst system designs are the ones where the trade-off was made accidentally.

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.