Skip to content
aposd-designing-deep-modules logo

Skill: aposd-designing-deep-modules

aposd-designing-deep-modules

Enforce Design-It-Twice workflow: generate 2-3 radically different approaches, compare them, then implement. Use when designing modules, APIs, or classes before implementation. Triggers on: design, create class, add module, implement feature, new service, API design, before implementing. Produces...

SKILL.md

Full skill instructions

Skill: aposd-designing-deep-modules

STOP - Before Implementing

Never implement your first design. Generate 2-3 radically different approaches, compare them, then implement.


Design-It-Twice Workflow

BEFORE implementing any module:

1. DEFINE - What are you designing? (class, API, service)
2. GENERATE - 2-3 RADICALLY different approaches
3. SKETCH - Rough outline each (important methods only, no implementation)
4. COMPARE - List pros/​cons, especially ease of use for callers
5. EVALUATE - Is there a clear winner or hybrid?
6. VERIFY - Does chosen design pass depth evaluation?
7. IMPLEMENT - Only then write the code

Time bound: Smaller modules: 1-2 hours. Larger modules: scale proportionally. This is design time, not implementation time.

If none attractive: Use identified problems to drive a new iteration of step 2.


Depth Evaluation

MetricDeep (Good)Shallow (Bad)
Interface sizeFew methodsMany methods
Method reusabilityMultiple use casesSingle use case
Hidden informationHighLow
Caller cognitive loadLowHigh
Common caseSimpleComplex

Exemplar: Unix file I/​O - 5 methods hide hundreds of thousands of lines of implementation.


Three Questions Framework

Ask these when designing interfaces:

QuestionPurposeRed Flag Answer
"What is the simplest interface that covers all current needs?"Minimize method count"I need many methods"
"In how many situations will this method be used?"Detect over-specialization"Just this one situation"
"Is this easy to use for my current needs?"Guard against over-generalization"I need lots of wrapper code"

Information Hiding Checklist

When embedding functionality in a module:

  • Data structures and algorithms stay internal
  • Lower-level details (page sizes, buffer sizes) hidden
  • Higher-level assumptions (most files are small) hidden
  • No knowledge shared across module boundaries unnecessarily
  • Common case requires no knowledge of internal details

Generality Sweet Spot

Target: Somewhat general-purpose

AspectShould Be
FunctionalityReflects current needs
InterfaceSupports multiple uses
SpecializationPushed up to callers OR down into variants

Push specialization UP: Top-level code handles specific features; lower layers stay general.

Push specialization DOWN: Define general interface, implement with device-specific variants.


Red Flags

Red FlagSymptomFix
Shallow ModuleInterface complexity rivals implementationCombine with related functionality
ClassitisMany small classes with little functionality eachConsolidate related classes
Single-Use MethodMethod designed for exactly one callerGeneralize to handle multiple cases
Information LeakageSame knowledge in multiple modulesConsolidate in single module
Temporal DecompositionStructure mirrors execution orderStructure by knowledge encapsulation
False AbstractionInterface hides info caller actually needsExpose necessary information
Granularity MismatchCaller must do work that belongs in moduleMove logic into module

Anti-Rationalization Table

Tempting ShortcutWhy It Feels RightWhy It's Wrong
"I'm confident in my first idea"Experience says it worksComplex problems defeat intuition; alternatives reveal hidden weaknesses
"I don't have time for multiple designs"Deadline pressureDesign time << debugging time for wrong abstraction
"The alternatives would be worse"Quick mental dismissalWithout sketching, you can't actually compare
"This is just a simple module"Scope seems smallSmall modules become core dependencies; getting them wrong cascades
"I'll refactor later if needed"Deferred painChanging interfaces is expensive; callers multiply
"The user already knows what they want"Seems respectfulThey know the PROBLEM, not necessarily the best SOLUTION
"This is a standard pattern"Feels like best practice"Standard" often means "first thing I saw"; make it explicit
"I already know which is best"Saves timeThen the comparison should be EASY, not skippable

Process Integrity Checks

Before finalizing your design choice, verify:

  • I wrote out alternatives BEFORE evaluating them (not just "thought through" them)
  • My comparison has at least one criterion where my preferred option loses
  • If I chose a hybrid, I stated what I'm sacrificing from each parent approach
  • Someone could reasonably disagree with my choice based on the same comparison

If user expresses impatience: Acknowledge it, but complete the process. Say: "I hear the urgency - this comparison takes 2 minutes and helps avoid rework."


Emergency Bypass Criteria

Skip the normal workflow ONLY when ALL of these conditions are true:

  1. Production is down RIGHT NOW (not "might break soon")
  2. Users are actively impacted, security breach in progress, OR data loss occurring
  3. The fix is minimal (rollback or single-line change)
  4. You commit to returning for proper implementation within 24 hours

Emergency does NOT mean:

  • "Demo in 30 minutes" — That's planning failure
  • "CEO is asking" — Authority pressure ≠ emergency
  • "Team is blocked" — They can wait for you to think
  • "We need this fast" — Speed pressure is when discipline matters MOST

Mandatory Output Format

When designing, produce:

## Design: [Component Name]

### Approaches Considered
1. [Approach A] - [1-2 sentence description]
2. [Approach B] - [1-2 sentence description]
3. [Approach C] - [1-2 sentence description] (if applicable)

### Comparison
| Criterion | A | B | C |
|-----------|---|---|---|
| Interface simplicity | | | |
| Information hiding | | | |
| Caller ease of use | | | |
| [Domain-specific criterion] | | | |

### Choice: [A/​B/​C/​Hybrid]
Rationale: [Why this wins, what's sacrificed]

### Depth Check
- Interface methods: [count]
- Hidden details: [list]
- Common case complexity: [simple/​moderate/​complex]

Chain

AfterNext
Design chosencc-pseudocode-programming

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View