定义现状 (Context):The current implementation in @module/service.py has a performance bottleneck under concurrent loads.
定义优化目标 (Goal):Refactor this module to use an asynchronous pattern with a connection pool to handle up to 500 concurrent requests.
提供示例 (Example):比如定义输入和输出。For instance, a call to process_data(items) should now return a Future object.
施加约束 (Constraints):Only use libraries present in requirements.txt. The solution must be compatible with Python 3.9+. Maintain the existing public API signature to avoid breaking changes.
TDD (Methodology):`First, write a failing benchmark test that reproduces the bottleneck. Then, implement the async changes. Finally, ensure all existing unit tests and the new benchmark pass.
一些技巧:
加入 think, think hard, think harder, ultrathink 等关键词,可以强制 AI 分配更多资源进行规划
Shift + Tab 切换到计划模式(Plan Mode),强制 AI 在动手前提交一份详细的行动计划。
Before fulfill a task or refactor some submodules, you should firstly use N parallel subagents or different aspects/perspectives to brainstorm possible plans. Compare their trade-offs in terms of performance, scalability, readability and maintainability, security etc. Do not implement any code.
质量与合规:利用 Hooks 系统,在项目中强制执行代码格式化、安全扫描等质量门禁。
Hooks 是在 Claude Code 生命周期特定事件点(如 PreToolUse, PostToolUse, UserPromptSubmit 等)执行的、用户定义的 Shell 命令。 它们提供了对 AI 行为的确定性控制,能将团队的非功能性需求(如安全、合规、质量)强制注入到 AI 对代码的每一次操作中,实现从“建议”到“规则”的转变。