先用伪代码梳理方案与迭代思路,再高效转成可执行代码。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "Designing Before Coding" 技能: 1. 下载 https://raw.githubusercontent.com/obra/clank/main/skills/coding/designing-before-coding/SKILL.md 2. 保存为 ~/.claude/skills/designing-before-coding/SKILL.md 3. 装好后重载技能,告诉我可以用了
请先不要直接写代码。先用伪代码设计一个支持去重、过滤空值、按时间降序排序的日志处理流程,比较两种实现思路的优缺点,再把你推荐的方案翻译成 Python 代码。
先给出结构清晰的伪代码与方案对比,再输出推荐方案的 Python 实现。
我有一个难维护的旧函数。请先根据以下需求把处理流程拆成伪代码模块,指出可复用部分、边界情况和潜在 bug,再给出重构后的 JavaScript 代码。需求如下:用户输入校验、错误提示、本地缓存、远程提交、失败重试。
输出模块化伪代码、风险分析与更易维护的重构代码。
请先用伪代码分析这道算法题,至少给出暴力法和优化法两种思路,说明时间与空间复杂度,再实现最优解并补充测试用例。题目:返回数组中和为目标值的两个下标。
包含多种解法的伪代码分析、复杂度说明、最优实现与测试样例。
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:
…
帮助开发者用早返回或表驱动方式简化嵌套条件分支,提升代码可读性。
帮助你为变量选择清晰准确、易维护的命名,提升代码可读性。
帮助开发者保持类接口抽象一致,避免混杂序列化、持久化等无关职责。
帮助你撰写不过时的代码注释,聚焦做什么与为什么而非时序背景。
帮助用户检索过往 Claude Code 对话,快速找回事实、决策与上下文线索。
为工程师生成分步实施计划,帮助在陌生代码库中快速落地任务。
帮助你在实施前先比较2到3种方案,选出更优设计与执行路径。
通过结构化追问与方案比较,把模糊想法梳理成可执行设计。
在创意与实现前梳理用户意图、需求与方案方向,降低返工风险。
根据需求先拆解多步骤任务,生成清晰可执行的实施计划
在设计完成后,为缺乏上下文的工程师生成可执行的详细实施计划。
通过测试驱动开发流程,先写测试再实现功能或修复缺陷。