一键导入
designing-before-coding
Design in pseudocode first, iterate approaches, then translate to code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Design in pseudocode first, iterate approaches, then translate to code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
| name | Designing Before Coding |
| description | Design in pseudocode first, iterate approaches, then translate to code |
| when_to_use | Before implementing any non-trivial routine or class. When jumping straight to code. When code feels hack-y or you're unsure how to proceed. When you catch yourself in "just one more compile" cycle. When tempted to code first and figure it out later. |
| version | 1.0.0 |
| languages | all |
Write the design in pseudocode BEFORE writing implementation code. Iterate through multiple approaches in pseudocode, pick the best, THEN translate to code.
Core principle: Once you start coding, you get emotionally involved with your code and it becomes harder to throw away a bad design. Design is cheap to change; code is expensive.
Violating the letter of the rules is violating the spirit of the rules.
Use for ANY programming task beyond trivial one-liners:
Red flags that you need this:
Don't skip when:
Before any design work:
If unclear, STOP. Get clarification before proceeding.
Name it BEFORE designing internals.
If you struggle to create a good name = WARNING SIGN.
Good name = clear, unambiguous, describes what routine does.
Before writing pseudocode:
Don't reinvent the wheel:
Use your code editor (it will become comments):
# Write general statement of purpose first
This routine outputs an error message based on an error code
supplied by the calling routine. The way it outputs the message
depends on the current processing state, which it retrieves
on its own. It returns a value indicating success or failure.
# Then write high-level pseudocode
set the default status to "fail"
look up the message based on the error code
if the error code is valid
if doing interactive processing, display the error message
interactively and declare success
if doing command line processing, log the error message to the
command line and declare success
if the error code isn't valid, notify the user that an internal
error has been detected
return status information
Pseudocode characteristics:
Critical step - don't skip:
If hard to explain or unclear, iterate the pseudocode. Don't proceed to code.
Don't settle for first design.
Try 2-3 different approaches in pseudocode:
Compare them:
Pick the best BEFORE coding.
Only after pseudocode is solid:
def report_error_message(error_code):
"""
This routine outputs an error message based on an error code
supplied by the calling routine. The way it outputs the message
depends on the current processing state, which it retrieves
on its own. It returns a value indicating success or failure.
"""
# set the default status to "fail"
status = Status.FAILURE
# look up the message based on the error code
error_message = lookup_error_message(error_code)
# if the error code is valid
if error_message.is_valid():
# determine the processing method
processing_method = current_processing_method()
# if doing interactive processing, display the error message
# interactively and declare success
if processing_method == ProcessingMethod.INTERACTIVE:
display_interactive_message(error_message.text)
status = Status.SUCCESS
# if doing command line processing, log the error message
# to the command line and declare success
elif processing_method == ProcessingMethod.COMMAND_LINE:
log_to_command_line(error_message.text)
status = Status.SUCCESS
else:
# if the error code isn't valid, notify the user that an
# internal error has been detected
display_interactive_message("Internal Error: Invalid error code")
# return status information
return status
Notes:
If routine is unusually buggy: start over. Don't hack around it.
| Stage | Action | Warning Sign |
|---|---|---|
| Prerequisites | Define inputs, outputs, pre/postconditions | Can't explain what routine does |
| Naming | Clear, unambiguous name | Struggling to name = design unclear |
| Errors | Think through what could go wrong | Forgetting error cases |
| Research | Check libraries and algorithms | Reinventing the wheel |
| Pseudocode | Write high-level design in English | Jumping to code syntax |
| Review | Explain to someone else | Can't explain clearly |
| Iterate | Try 2-3 approaches | Settling for first idea |
| Translate | Mechanical conversion to code | Fighting the language |
| Check | Mental execution, testing | "Just one more compile" |
❌ Skipping pseudocode: "It's simple, I'll just code it" ✅ Fix: Even simple routines benefit. Takes 30 seconds, saves debugging time.
❌ Pseudocode too low-level: Writing programming syntax in comments ✅ Fix: Use plain English describing WHAT, not HOW. Should work in any language.
❌ Settling for first design: Implementing first idea that comes to mind ✅ Fix: Try 2-3 approaches, compare, pick best.
❌ Compiling too early: "Let me compile and see if it works" ✅ Fix: Don't compile until you're convinced it's right. Avoid hack-compile-fix cycle.
❌ Coding before understanding: "I'll figure it out as I code" ✅ Fix: If you don't understand at pseudocode level, you won't understand at code level.
❌ Vague name accepted: "I'll think of a better name later" ✅ Fix: Vague name = vague design. Fix the design NOW.
If you wrote implementation code without pseudocode first, you've violated the process.
No exceptions:
Required steps:
The hours already spent are sunk cost. Don't throw good time after bad by keeping suboptimal design.
"But it works!" doesn't mean it's the best design. Working code without good design is technical debt.
Even with production down and $15k/minute at stake:
Time comparison:
The pressure makes pseudocode FEEL wasteful. It's not. It's faster.
For true 5-line fixes:
Emergency doesn't override the principle. It reinforces it.
Debug cycles under pressure are even more expensive (stress, mistakes, production impact).
| Excuse | Reality |
|---|---|
| "It works already" | Working ≠ best design. Pseudocode reveals better alternatives. |
| "Keep code as reference" | You'll bias toward it. Set it aside completely. |
| "Too simple to design" | Simple code still benefits. Takes 30 seconds. |
| "Emergency, no time" | Pseudocode is faster than debug cycles. Always worth 2 minutes. |
| "I designed in my head" | Undocumented mental design = didn't happen. Must write it. |
| "Ship it, document after" | Pseudocode-after doesn't catch design problems. Too late. |
| "Production down, skip process" | Broken process = how production got broken. Don't compound it. |
| "Just this once" | "Just this once" becomes "always this once." No exceptions. |
Before marking work complete:
Can't check all boxes? Return to Step 5 (Write pseudocode).
Before coding:
After coding (without pseudocode):
All of these mean: Stop coding. Return to pseudocode.
PPP and TDD work together. Both require design before implementation.
Combined process:
Order is critical:
Both skills mandate: NO implementation code without design first.
TDD says write the test first. PPP says design the test in pseudocode before writing test code. They reinforce each other.
From Code Complete research:
Key quote: "The picture of the software designer deriving his design in a rational, error-free way from a statement of requirements is quite unrealistic. No system has ever been developed that way." - David Parnas
Design is sloppy and iterative. Pseudocode keeps that sloppiness cheap.
Fork, clone to ~/.clank, run installer, edit CLAUDE.md
RED-GREEN-REFACTOR for process documentation - baseline without skill, write addressing failures, iterate closing loopholes
Skills wiki intro - mandatory workflows, search tool, brainstorming triggers
Interactive idea refinement using Socratic method to develop fully-formed designs
Execute detailed plans in batches with review checkpoints
Execute implementation plan by dispatching fresh subagent for each task, with code review between tasks