software-design-philosophy
Software design philosophy guide based on John Ousterhout's "A Philosophy of Software Design." Use this skill during: code reviews, architecture discussions, API design, module decomposition decisions, refactoring guidance, complexity analysis, naming and commenting improvements, error handling strategy design. Trigger when the user mentions "code is too complex", "how to split modules", "interface design", "reduce coupling", "deep/shallow modules", "information leakage", "error handling", "code readability", "design philosophy", "pull complexity down", "define errors out of existence", or similar topics. Also trigger for any code review where design quality feedback is requested.
What this skill does
# A Philosophy of Software Design — Distilled Guide > Source: John Ousterhout, *A Philosophy of Software Design* > Central thesis: **The core challenge of software design is managing complexity.** --- ## I. Complexity: Know the Enemy ### Definition Complexity is anything related to the structure of a software system that makes it **hard to understand and modify**. Complexity is not the same as system size — a small system can be complex, and a large well-designed system can be manageable. ### Three Symptoms of Complexity 1. **Change Amplification**: A seemingly simple change requires code modifications in many different places. 2. **Cognitive Load**: Developers must absorb a large amount of information to complete a task safely. Note: fewer lines of code ≠ simpler — sometimes more code is actually simpler because it reduces cognitive load. 3. **Unknown Unknowns**: It's unclear which code must be modified or what information is needed to complete a task. This is the most dangerous symptom. ### Two Root Causes 1. **Dependencies**: A piece of code cannot be understood or modified in isolation; it relates to other code that must also be considered. 2. **Obscurity**: Important information is not obvious — vague names, missing docs, implicit conventions, hidden constraints. ### Key Insight - **Complexity is incremental**: It's not caused by a single catastrophic error; it accumulates through thousands of small decisions. - Therefore you must adopt a **zero-tolerance** mindset — every bit of "minor" complexity matters. --- ## II. Strategic vs. Tactical Programming ### Tactical Programming (Anti-pattern) - Goal: get features working as quickly as possible. - Mindset: "Just make it work", "We'll refactor later." - Result: complexity accumulates fast, tech debt spirals out of control. ### Strategic Programming (Recommended) - Goal: produce great design; working code is a byproduct. - Mindset: **invest roughly 10–20% of development time in design improvements.** - Practices: - Look for opportunities to improve design with every change. - Working code is not enough — design quality matters equally. - The increments of software development should be **abstractions**, not features. --- ## III. Deep Modules: The Most Important Design Concept ### Core Metaphor Think of a module as a rectangle: - **Width** = complexity of its interface - **Height/Depth** = amount of functionality hidden inside **Deep module**: simple interface, rich implementation. (Good design) **Shallow module**: complex interface, does very little. (Bad design 🚩) ### Classic Examples - **Deep**: Unix file I/O — just 5 syscalls (open, read, write, lseek, close) expose a powerful file system. - **Shallow**: Java I/O — reading a file requires composing FileInputStream, BufferedInputStream, ObjectInputStream, etc. ### Practical Principles - Design interfaces so the **most common usage is as simple as possible**. - A simple interface matters more than a simple implementation. - Rare use cases can accept more complex calling patterns, but the common path should never pay for them. --- ## IV. Information Hiding and Information Leakage ### Information Hiding - Each module should encapsulate **design decisions** (knowledge), exposing only a simplified interface. - Hidden information includes: data structures, algorithms, low-level mechanisms, policy decisions. - Information hiding minimizes inter-module dependencies. ### Information Leakage 🚩 Red Flag - When the same design decision is reflected in multiple modules, information has leaked. - **Temporal decomposition** is a common source: splitting modules by execution order (rather than by information hiding) causes steps to share excessive knowledge. ### Fixing Leakage - Merge shared knowledge into a single module. - If merging isn't possible, unify the shared information behind a single deep module. --- ## V. General-Purpose vs. Special-Purpose Modules ### Core Principle: General-purpose modules are usually deeper. - A general interface is simpler than a specialized one because it covers more use cases with fewer methods. - When designing a new module, ask: **What is the most general-purpose interface that can satisfy my current needs?** ### Judgment Criteria - The interface should be general enough to support multiple use cases without modification. - But the implementation can do only what's currently needed (don't over-build). - General-purpose and special-purpose code should be **cleanly separated**. --- ## VI. Different Layers, Different Abstractions ### Principle - A software system has multiple layers; each layer should provide a **different abstraction** from its adjacent layers. - If two layers have similar abstractions, the layering is wrong. ### Pass-Through Method 🚩 Red Flag - A method that does almost nothing except forward its arguments to another method with a similar signature. - This signals that the layers don't offer different abstractions — the responsibility split is flawed. ### Pass-Through Variable 🚩 Red Flag - A variable threaded from top to bottom through layers that don't use it. - Solutions: context objects, dependency injection, or rethinking module boundaries. --- ## VII. Pull Complexity Downward ### Core Principle - When complexity is unavoidable, the **module should absorb it internally** rather than pushing it to callers. - Most modules have more users than developers — it's better for developers to suffer than for every user to suffer. ### Anti-patterns - Turning hard decisions into configuration parameters and pushing them to sysadmins. - Throwing exceptions for uncertain conditions and letting callers handle them. - These save effort in the short term but amplify complexity system-wide. --- ## VIII. Define Errors Out of Existence ### Core Insight - Exception handling is one of the biggest sources of complexity. - Reducing the number of exceptions that must be handled is one of the best techniques for reducing complexity. ### Strategies 1. **Redefine semantics so the error condition cannot arise.** - Example: `unset(key)` succeeds even if the key doesn't exist — it simply guarantees "after the call, the key does not exist." - Example: `substring(start, end)` auto-clips out-of-bounds parameters instead of throwing. 2. **Exception Masking**: Detect and handle exceptions at a low level so they never reach callers. 3. **Exception Aggregation**: Handle multiple exception types in one centralized place instead of scattering handlers at every call site. ### Important Distinction - This is not about ignoring errors — it's about **designing better semantics so error conditions simply aren't errors**. - Errors that truly require reporting (e.g., lost network packets) must still be handled properly. --- ## IX. Design It Twice - For any important design decision, conceive **at least two different approaches** before choosing. - Even if the first idea seems great, force yourself to think of an alternative. - Comparison dimensions: interface simplicity, generality, performance, implementation difficulty. - This habit significantly improves design quality. --- ## X. The Philosophy of Comments ### Why Write Comments 1. Comments capture **design decisions and intent** that code cannot express. 2. Comments are part of the abstraction — good interface docs mean users don't have to read the implementation. 3. Writing comments **early** exposes design problems before you invest in code. 4. Good comments dramatically reduce cognitive load. ### What Comments Should Describe - **Non-obvious information**: the *why*, constraints, boundary conditions, side effects — things you can't see in the code. - Comments should NOT repeat what the code already says. 🚩 Red Flag: Comment Repeats Code ### Comment Layers - **Interface comments**: describe *what* and *why* — no implementation details. - **Implementation comments**: explain *how* and *why this approach* — why the code
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.