Files
nexus/wiki/concepts/上下文固定.md

31 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "上下文固定"
type: concept
tags: [vibe-coding, context, AI, constraints]
---
## Definition
上下文固定Context Anchoring是 Vibe Coding 范式的第二原则:通过持久化文件(.cursorrules、SPEC.md、技术架构文档维持 AI 跨对话的上下文一致性,防止 AI 在长对话中遗忘项目约束和设计决策。
## Problem It Solves
- AI 对话窗口有限:长对话后 AI 会丢失早期决策
- AI 幻觉缺少明确约束时AI 会自行创造"合理"但错误的实现
- 风格漂移AI 在不同对话中可能给出风格不一致的代码
## Mechanisms
1. **.cursorrules**Cursor IDE 项目级 AI 行为规则文件(如强制 Doc 注释)
2. **SPEC.md**:功能规格文档,作为 AI 每次对话的入口参考
3. **TECH_STACK.md**:技术栈锁定,防止 AI 随意更换框架
4. **STATE.yaml**:项目状态文件,多 Agent 协作时维护共同上下文
## Related Concepts
- [[Vibe Coding]]:上下文固定是 Vibe Coding 三要素之一
- [[规划驱动]]:规划文档是上下文固定的基础
- [[项目规则]].cursorrules 是上下文固定的具体实现
- [[去中心化协调]]STATE.yaml 是上下文固定在多 Agent 场景的延伸
## Aliases
- Context Anchoring
- 上下文锚定
- 上下文维持