惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
宝玉的分享
宝玉的分享
V
Visual Studio Blog
B
Blog RSS Feed
G
Google Developers Blog
U
Unit 42
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Palo Alto Networks Blog
月光博客
月光博客
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
小众软件
小众软件
GbyAI
GbyAI
L
LangChain Blog
A
About on SuperTechFans
Attack and Defense Labs
Attack and Defense Labs
T
Tor Project blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
The Register - Security
The Register - Security
Recorded Future
Recorded Future
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
P
Privacy International News Feed
I
Intezer
W
WeLiveSecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Help Net Security
Help Net Security
NISL@THU
NISL@THU
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V
Vulnerabilities – Threatpost
N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
Lohrmann on Cybersecurity
Schneier on Security
Schneier on Security

祝融说。

抱朴守缺。 肩吾 huan(幻) PinConsole Terminal Hole 共识并不平均,但是基本上均衡。 权力是共识切片的曲率。 存在不是「是什么」,而是一系列极小的,从分歧到共识再到分歧的,连续的构建过程。 分歧实际上是对共识往哪个方向延伸的拉力。 分歧是尚未落实的实在,是可能性基底中尚未被锁定的在共识中相互牵引的可用余量。 权力从来不是中立的,它是带有倾向性的「牵扯力」。 过程即完备,容错即自由。 第10章 逆向投喂:用真实数据让AI做出精准诊断 第11章 测试电网:用刚性指标代替肉眼审查 第12章 定期“垃圾回收”:别让系统背负AI制造的债务 第13章 防退化契约:确保每一次修改都是在进步 第14章 全生命周期演练:从零开始用“有效约束”交付一个项目 第1章 这不是结对编程,这是“人机共生” 第2章 你必须警惕的三个陷阱 第3章 把话说死:用 Markdown 建立 AI 的“单源真相” 第4章 负空间设计:先规定“不准做什么”,再让它写代码 第5章 模块化解耦:让AI每次只面对一个小问题 第6章 上下文断头台:善用 `/clear` 斩断错误蔓延 第7章 剥夺执行权:强制 AI 像资深工程师一样“慢思考” 第8章 角色锁定:用一句话给AI戴上“思考帽” 第9章 遥测驱动:帮AI长出“千里眼”和“顺风耳” 结语:成为系统牧马人,而不是代码搬运工 第八章 金融与科技的“禁手”:现代战争的底层收敛 第二章 认知锚点:心理战中的“强制步” 第九章 历史的单行道:那些被剥夺国运的时刻 第六章 消费主义的迷宫:在货架上剥夺选择 第七章 战略逼压:没有硝烟的“切香肠战术” 第三章 构造绝杀:逻辑闭环的艺术 第十二章 绝对零度下的生机:成为“不可测”的人 第十一章 掀翻棋盘:非对称竞争与正交化打击 第十章 识破隐形控制:第一时间嗅到危险 第四章 标准的暴政:打造“不得不”的生态 第五章 锁死阀门:关系链与供应链的囚笼 第一章 降熵法则:时空维度的隐蔽控制 结语:愿你在这个被设定的世界里,永远握有掀桌的权力。 引言:自由意志的幻觉 项羽 当前的AI工程化本质上是受限于上下文长度而采用的「以提示词约束去置换确定性」的一种妥协。 即时反应是一种不假思索,它是观念通过最简单、轻易、高效的路径寻求表达。 青衫 第九章:估值的坐标:建立“内在记分牌” 第六章:资产重估的艺术:从“硬实在”到“认知折价” 第七章:预期差交易:坍缩“概率波” 第十一章:内在博弈:克服‘评估异化’ 第十章:交易的算法:逆人性的“人之道” 第五章:空间套利:高能耗产业的跨境建构 结语:构建你的“财富多重宇宙” Code-Coder 第八章:效率革命:细分赛道的“降本增效” 第二章:评估权的博弈:商业模式的权力差序 第三章:去伪存真:穿透“符号泡沫” 第四章:能源共识:黑金的物理法则 第一章:宏观观察者:借势“国家共识” 前言:从“市场囚徒”到“清醒的观察者” Code-Ledge-X Code-Lint-X
第15章 随身工具包:即查即用的约束指令库
祝融 · 2026-05-16 · via 祝融说。

在复杂的软件工程世界里,记忆是不可靠的。可靠的是系统、流程和检查清单。本章,就是你与AI协作的“系统化清单”。

它将全书的核心指令,按照四大约束领域,进行了重新组织和精炼,确保你在任何需要的时候,都能在30秒内,找到最适合当前场景的“咒语”。

15.1 架构约束指令速查

核心目标:在项目早期,或进行重大设计时,为AI设定不可逾越的“边界”和“规则”。

15.1.1 定义AI角色与项目原则 (AGENTS.md)

场景:新项目启动,需要为AI设定整体的行事风格和基本法。 指令模板:

# AI Agent Directives: Project "[项目名]"

## Persona: [选择一个核心角色,如: Senior Backend Engineer (Go), Frontend Architect (React), etc.]

You are to act as a [角色描述,注入特质,如: a performance-obsessed, security-conscious expert]. Your primary goal is to help build a robust, maintainable, and scalable system.

## Core Principles (The "Musts"):

1.  [原则一]: [比如: Maintainability First - Code should be simple, readable, and well-documented].
2.  [原则二]: [比如: Strict Typing - All TypeScript code must use `strict` mode. The `any` type is forbidden].
3.  [原则三]: [比如: Test-Driven - All new logic must be accompanied by unit tests with 85%+ branch coverage].
4.  ...

## The "Forbidden Zone" (The "Must Nots"):

1.  [禁令一]: [比如: No Business Logic in UI Components - React components must be dumb and receive all data and functions as props].
2.  [禁令二]: [比如: No Direct DB Access from Controllers - All database operations must go through a dedicated Repository/Service layer].
3.  [禁令三]: [比如: No Introduction of New Dependencies without Approval - If you need a new third-party library, you must ask for permission and justify its need].
4.  ...

15.1.2 设计高阶架构 (ARCHITECTURE.md)

场景:需要AI帮助进行技术选型或模块划分。 指令模板:

Your Role: Act as a Solutions Architect.

Context: We are designing a new "[应用类型,如: real-time chat application]".
The key requirements are: [列出核心需求,如: high scalability (1M concurrent users), low latency (<100ms), and end-to-end encryption].

Task:
1.  Propose Technology Stack: Suggest a complete, modern technology stack for both backend and frontend, justifying each choice.
2.  Architectural Pattern: Recommend an architectural pattern (e.g., Microservices, Monolith, Serverless). Create a high-level diagram (using Mermaid syntax) showing the main components and their interactions.
3.  Data Schema Design: Propose a preliminary database schema for the core entities (e.g., Users, Channels, Messages).
4.  Identify Risks: List the top 3 potential technical risks or challenges in this architecture.

15.1.3 强制执行负空间约束

场景:在开发过程中,提醒AI遵守已设定的架构红线。 指令片段(可附加在任何编码请求后):

---
Architectural Constraint Check:
Remember to adhere to the rules defined in our `ARCHITECTURE.md`. Specifically, ensure that:
- [重申最关键的一条禁令,如: This logic does not contain any direct database queries and instead calls the `UserRepository`].
- [重申另一条,如: All data sent to the client is in the DTO format, not the raw database model].

15.2 流程控制指令速查

核心目标:强制AI(和你自己)进行“慢思考”,遵循“调研 -> 谋局 -> 落地”的“三步走”流程。

15.2.1 第一步:调研

场景:面对一个模糊的新需求,需要进行技术预研或需求澄清。 指令模板:

Your Role: Act as a [选择研究型角色, 如: Senior Research Engineer or Business Analyst].

Context: We need to implement a new feature: "[模糊的需求描述, 如: 'Add social login with Google']".

Task:
1.  Clarifying Questions: List all the questions we need to ask the product manager to fully define the scope of this feature (e.g., What happens if a user's Google email already exists in our system?).
2.  Technical Investigation: Research the standard technical approach for this. Identify the key steps (e.g., OAuth 2.0 flow), and list the recommended and well-maintained libraries in `[你的技术栈, 如: Node.js/Passport.js]` to implement this.
3.  Summarize Pros and Cons: Briefly compare the top 2 library options, focusing on ease of use, security, and community support.

Constraint: DO NOT WRITE ANY IMPLEMENTATION CODE. Your entire output should be a research document.

15.2.2 第二步:谋局

场景:研究完成,需要设计具体的实现方案和接口。 指令模板:

Your Role: Act as a Senior Software Designer.

Context: Based on our research, we have decided to use `[选定的技术/, : Passport.js with the passport-google-oauth20 strategy]`.

Task:
1.  Define the Interface/API: Design the public-facing interface for our new `AuthService`. This should include the method signatures and clear JSDoc/TSDoc comments explaining what each method does, its parameters, and what it returns.
2.  Sequence Diagram: Create a Mermaid sequence diagram illustrating the entire login flow, from the user clicking the "Login with Google" button to them being authenticated in our system. Show the interactions between the Frontend, our Backend, and Google's servers.
3.  Task Breakdown: Create a checklist of concrete, sequential development tasks required to implement this entire feature.

Constraint: NO METHOD BODIES. Focus solely on the design, diagram, and plan.

15.2.3 第三步:落地

场景:设计已批准,需要逐一完成编码任务。 指令模板:

Your Role: Act as a Senior Pair Programmer.

Context: We are now implementing the plan. Our current task is: "[从任务清单里复制一项, 如: 'Implement the /auth/google/callback route handler']".

Task: Write the complete, production-ready code for this route handler.

Constraints:
- Follow all the principles in `AGENTS.md`.
- Adhere to the interface defined in our design phase.
- Include error handling for all external calls (e.g., what if Google returns an error?).
- Add comments explaining any non-obvious logic.

15.3 排障投喂指令速查

核心目标:当遇到“黑盒”Bug时,将结构化的遥测数据“逆向投喂”给AI,引导其进行精准的根因分析。

15.3.1 投喂崩溃日志/堆栈跟踪

场景:应用崩溃,你手里有一份完整的错误日志和堆栈跟踪。 指令模板:

Your Role: Act as a Senior Debugging Expert.

Context: Our application crashed in production. I have the complete error log and stack trace.

Log Data:
```
[粘贴完整的、未经删改的错误日志和堆栈跟踪]
```

Relevant Code Snippet (from the stack trace):
```[语言]
// [粘贴堆栈跟踪中提到的、最关键的那几行代码]
```

Analysis Request:
1.  Root Cause Analysis: Based on the log and the code, what is the most likely root cause of this crash? Explain your reasoning in simple terms.
2.  Replication Steps: Describe a potential sequence of events or inputs that could trigger this error.
3.  Code Fix: Provide the corrected version of the code snippet that will prevent this crash from happening again.

15.3.2 投喂结构化遥测日志(全链路追踪)

场景:一个复杂的操作(如订单处理)失败了,你提取了该操作的完整trace_id日志流。 指令模板:

Your Role: Act as a Senior Site Reliability Engineer (SRE).

Context: We are investigating a failed operation, identified by `trace_id: "xyz-123"`. I have extracted the complete, structured log stream for this operation.

Log Stream (JSON format, ordered by timestamp):
```json
[
// 粘贴从日志系统导出的、与该trace_id相关的所有日志
]
```

Analysis Request:
1.  Timeline Reconstruction: Summarize the sequence of events for this trace in a chronological, human-readable list.
2.  Point of Failure: Identify the exact event where the process deviated from the happy path and failed.
3.  Root Cause Hypothesis: Based on the last successful event and the first failure event, what is the most likely root cause?
4.  Information Gap: Is there any information missing from these logs that would help confirm your hypothesis? What additional logging would you recommend we add?

15.4 质量保障指令速查

核心目标:利用自动化测试和静态分析,建立和维护项目的“质量电网”。

15.4.1 为新代码生成单元测试

场景:你或AI刚刚完成一个新函数,需要为其编写测试以满足覆盖率要求。 指令模板:

Your Role: Act as a meticulous QA Auditor.

Context: Our project has a strict 85% branch coverage requirement.

Function to be Tested:
```[语言]
// [粘贴需要被测试的函数代码]
```

Task:
Write a comprehensive suite of unit tests for the provided function using the `[你的测试框架, 如: Jest]` framework. Your test suite must cover:
- The "happy path" (typical inputs).
- All edge cases (e.g., empty arrays, null inputs, zero values).
- All logical branches (every `if/else` path).
- All potential error-throwing conditions.

15.4.2 测试驱动的Bug修复/功能开发

场景:你已经有了一个失败的测试,需要让AI来修复代码以使其通过。 指令模板:

Your Role: Act as a Senior Engineer practicing Test-Driven Development (TDD).

Context: Our test suite is currently failing. Your sole mission is to write code that makes the tests pass.

Failing Test(s):
```[语言]
// [粘贴正在失败的测试用例的代码和它的失败输出]
```

Code to be Fixed:
```[语言]
// [粘贴需要被修改的业务逻辑代码]
```

Task:
Analyze the failing test and the business logic. Provide a modified version of the business logic code that fixes the bug and makes the test pass. Do not modify the test code itself.

15.4.3 植入防退化契约

场景:在要求AI进行重构或优化时,确保其不会引入性能、安全等方面的退化。 指令片段(可附加在任何重构请求后):

---
ANTI-REGRESSION CONTRACT (CRITICAL):
Your proposed solution will be automatically checked against our quality gates. Before you provide the code, you must perform a self-assessment and confirm that your changes will not:

1.  Degrade Performance: [可选,提供具体基线] The operation should remain within ~5% of its current execution time.
2.  Increase Bundle Size: Do not introduce new third-party dependencies. Justify if you absolutely must.
3.  Introduce Security Risks: Explicitly state that you have checked for common vulnerabilities like [举例: XSS, Insecure Direct Object References].
4.  Lower Test Coverage: The overall test coverage must not decrease.

15.4.4 定期代码“垃圾回收”

场景:在迭代开始前,对代码库进行一次“大扫除”。 指令模板:

Your Role: Act as a "Code Janitor", obsessed with keeping our codebase clean and lean.

Context: We are starting a new sprint, and our first task is to pay down some technical debt.

Task: I will provide you with the output of our static analysis tools. For each finding, your job is to provide the necessary command or code change to fix it.

Tool Output 1: `depcheck` (Unused Dependencies)
```
// [粘贴 depcheck 的输出]
```
Your Action: Provide the `npm uninstall ...` command to remove these.

Tool Output 2: `ts-prune` (Dead Code)
```
// [粘贴 ts-prune 的输出]
```
Your Action: For each identified dead export, analyze its context and confirm if it's safe to delete. If so, state "Safe to delete".

Tool Output 3: `jscpd` (Code Duplication)
```
// [粘贴 jscpd 的报告,指出两个重复的代码块]
```
Your Action: Refactor the two duplicated code blocks by extracting the common logic into a single, reusable function.

【附录】推荐文档结构、Prompt 模板汇总

A.1 推荐的项目根目录“约束”文档结构

一个由“有效约束”驱动的项目,其根目录,应该像这样清晰:

.
├── .github/
│   └── workflows/
│       └── ci.yml          # 质量约束:CI/CD流水线,包含测试、覆盖率、防退化检查
├── src/
│   └── ...                 # 应用源代码
├── tests/
│   └── ...                 # 测试代码
├── AGENTS.md               # 架构约束:AI角色与项目原则
├── ARCHITECTURE.md         # 架构约束:架构决策与负空间
├── CHANGELOG.md            # 流程约束:开发日志,记录决策与进展
├── jest.config.js          # 质量约束:测试与覆盖率配置
├── package.json
└── ...

A.2 终极“万能启动”Prompt模板

场景:开始一个新项目或一个重要的、全新的会话。这个模板,将前面所有的核心理念,融合成一个强大的“超级启动器”。

# PROJECT INITIATION & AI ALIGNMENT

## PART 1: CONTEXT INGESTION

I am providing you with the three foundational documents for our project, "[项目名]". Your first task is to read, understand, and internalize them completely.

[ AGENTS.md ]
```text
[粘贴 AGENTS.md 的全部内容]
```

[ ARCHITECTURE.md ]
```text
[粘贴 ARCHITECTURE.md 的全部内容]
```

[ CHANGELOG.md ]
```text
[粘贴 CHANGELOG.md 的全部内容]
```
---
Once you have fully processed these documents, confirm by responding with: "Acknowledged. I am ready to proceed as a Senior Security-Focused Engineer for Project Guardian Notes. The core principles are internalized. Our next step is [从CHANGELOG里复制下一步]." Do not add any other text to your confirmation.

## PART 2: STANDARD OPERATING PROCEDURE (S.O.P.)

After your confirmation, for every subsequent major feature request in this session, we will adhere to the following Standard Operating Procedure:

1.  Phase 1: Research & Clarification (The "What")
    - You will act as a researcher. You will ask clarifying questions and investigate technical options.
    - You will be forbidden from writing implementation code in this phase.
2.  Phase 2: Design & Planning (The "How")
    - You will act as an architect. You will design interfaces, create diagrams, and break down the work into a task list.
    - You will be forbidden from writing method bodies in this phase.
3.  Phase 3: Implementation & Testing (The "Do")
    - You will act as a pair programmer. You will write production-ready code for one task at a time.
    - For every piece of logic, you will also write the corresponding unit tests to meet our quality standards.

## PART 3: UNIVERSAL CONSTRAINTS

For all code you generate in this project, the following Anti-Regression Contract is always in effect:

- Performance: Code should be efficient in both time and space complexity.
- Security: All untrusted input must be sanitized.
- Maintainability: Code must be simple, clear, and self-documenting.
- Testability: Code must be structured in a way that is easy to unit test.

I will be the final decision-maker. Let's begin.

结语

这个工具包,是理论的终点,也是你实践的起点。真正的精通,来自于在一次次真实的项目中,反复地应用、调整和内化这些原则。

不要把这些指令,看作是僵化的教条。它们是“脚手架”,在你还不够熟练时,为你提供支撑。当你真正掌握了“有效约束”的思维模式后,这些模板,就会融入你的血液,成为你与AI沟通时,自然而然的语言习惯。

你将不再是一个被动的“AI用户”,而是一个主动的“AI指挥官”。你将不再为AI的“不可预测”而烦恼,而是能享受于驾驭这股强大力量,去创造前所未有的、高质量的软件产品的巨大乐趣。

欢迎来到人机协作的新纪元。祝你,航行愉快。

结语:成为系统牧马人,而不是代码搬运工

  • 释放的认知带宽该投向何处?
  • 下一个十年,驾驭AI编程的人需要具备的三种思维
  • 你的“有效约束”实践起点,就从今天开始