context-surfing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContext Surfing
Context Surfing
Install
安装
bash
npx skills add pskoett/pskoett-ai-skills/skills/context-surfingThe agent rides the wave of peak context. When the wave crests, it commits. When it detects drift, it pulls out cleanly — saving state, handing off, and letting the next session catch the next wave.
No wipeouts. No zombie sessions. Only intentional, high-fidelity execution.
bash
npx skills add pskoett/pskoett-ai-skills/skills/context-surfingAgent会借助峰值上下文的“浪潮”开展工作。当浪潮达到顶峰时,它会提交成果;当检测到上下文漂移时,它会干净利落地退出——保存状态、完成交接,让下一个会话承接下一波“浪潮”。
不会出现“翻船”情况,也不会有“僵尸会话”,只有目标明确、高保真度的执行过程。
Mental Model
思维模型
Think of context like an ocean wave:
- Paddling in = loading the intent frame, plan, and initial context. Energy is building.
- The peak = full context coherence. The agent knows exactly what it's doing and why. This is when to execute.
- The shoulder = context starting to flatten. Still rideable, but output density is dropping.
- The close-out = drift. Contradiction, hedging, second-guessing, or hallucinated details. Wipe-out territory.
The skill's job: ride as long as the wave is good, exit before it closes out.
可以把上下文想象成海浪:
- 划浪阶段 = 加载意图框架、计划和初始上下文,能量正在积累。
- 顶峰阶段 = 上下文完全连贯,Agent清楚地知道要做什么以及原因,这是执行的最佳时机。
- 回落阶段 = 上下文开始弱化,仍可继续执行,但输出质量会下降。
- 消散阶段 = 出现上下文漂移,表现为矛盾表述、含糊其辞、反复纠结或生成幻觉信息,这是“翻船”的风险区域。
本技能的职责:在浪潮状态良好时持续推进,在浪潮消散前及时退出。
Lifecycle Position
生命周期定位
[plan-interview] → [intent-framed-agent] → [context-surfing ACTIVE] → [simplify-and-harden] → [self-improvement]Context Surfing is the execution layer. It wraps all work between intent capture and post-completion review. Simplify-and-harden and self-improvement are the next steps in the pipeline — they run after context-surfing completes, not as conditions that end it.
[plan-interview] → [intent-framed-agent] → [context-surfing 激活] → [simplify-and-harden] → [self-improvement]Context Surfing是执行层技能,它包裹着意图捕获到完成后评审之间的所有工作。Simplify-and-harden和self-improvement是流程中的后续步骤——它们会在context-surfing完成后运行,而非作为终止它的条件。
Relationship with intent-framed-agent
与intent-framed-agent的关系
Both skills are live during execution. They monitor different failure modes:
- intent-framed-agent monitors scope drift — am I doing the right thing? It fires structured Intent Checks when work moves outside the stated outcome.
- context-surfing monitors context quality drift — am I still capable of doing it well? It fires when the agent's own coherence degrades (hallucination, contradiction, hedging).
They are complementary, not redundant. An agent can be perfectly on-scope while its context quality degrades (e.g., it's doing the right thing but starting to hallucinate details). Conversely, scope drift can happen with perfect context quality (the agent deliberately chases a tangent). Intent-framed-agent's Intent Checks continue firing alongside context-surfing's wave monitoring.
Precedence rule: If both skills fire simultaneously (an Intent Check and a drift exit at the same time), context-surfing's exit takes precedence. Degraded context makes scope checks unreliable — resolve the context issue first, then resume scope monitoring in the next session.
两个技能会在执行过程中同时运行,分别监控不同的失效模式:
- intent-framed-agent 监控范围漂移——我是否在做正确的事?当工作超出既定目标时,它会触发结构化的意图检查。
- context-surfing 监控上下文质量漂移——我是否仍能高质量地完成工作?当Agent自身的连贯性下降(如生成幻觉信息、出现矛盾表述、含糊其辞)时,它会触发退出。
二者互为补充,而非重复。Agent可能完全在既定范围内工作,但上下文质量已下降(例如,它在做正确的事,但开始生成幻觉细节)。反之,也可能上下文质量完好,但出现范围漂移(Agent刻意追逐无关内容)。Intent-framed-agent的意图检查会与context-surfing的浪潮监控同时进行。
优先级规则: 如果两个技能同时触发(意图检查和漂移退出同时发生),context-surfing的退出操作优先。上下文质量下降会导致范围检查不可靠——先解决上下文问题,再在下一个会话中恢复范围监控。
When to Use the Full Pipeline
何时使用完整流程
Not every task needs all five skills. Match pipeline depth to task complexity:
| Task Type | Skills to Use |
|---|---|
| Trivial (rename, typo fix) | None — just do it |
| Small (isolated bug fix, single-file change) | |
| Medium (feature in known area, multi-file) | |
| Large (complex refactor, new architecture, unfamiliar codebase) | Full pipeline |
| Long-running (multi-session, high context pressure) | Full pipeline with |
When in doubt, start light. Add skills if you notice drift or quality issues mid-task.
并非所有任务都需要全部五个技能,需根据任务复杂度匹配流程深度:
| 任务类型 | 适用技能 |
|---|---|
| 简单任务(重命名、修复拼写错误) | 无——直接执行即可 |
| 小型任务(孤立Bug修复、单文件修改) | 仅使用 |
| 中型任务(已知领域的功能开发、多文件修改) | |
| 大型任务(复杂重构、新架构搭建、陌生代码库开发) | 完整流程 |
| 长时间运行任务(多会话、高上下文压力) | 完整流程,其中 |
拿不准时,先从精简流程开始。如果在任务执行中发现漂移或质量问题,再添加相应技能。
Activation
激活方式
This skill is live the moment the intent frame and plan are established. No explicit invocation needed.
At activation, load and confirm:
- The intent frame (from intent-framed-agent output)
- The plan (from plan-interview output)
- The current session state from the Entire CLI (if available)
- All project context files (see below)
一旦意图框架和计划确定,该技能会自动激活,无需显式调用。
激活时,需加载并确认:
- 意图框架(来自intent-framed-agent的输出)
- 计划(来自plan-interview的输出)
- 来自Entire CLI的当前会话状态(若可用)
- 所有项目上下文文件(见下文)
Entire CLI Integration
与Entire CLI的集成
Entire CLI (github.com/entireio/cli) provides persistent session state that serves as external ground truth for drift checks and handoff files.
At activation, detect Entire:
bash
entire status 2>/dev/null- If it succeeds, use Entire as the session state backend. Log completions, in-progress items, and scope notes to it as work progresses.
- If unavailable or failing, continue without it. Use the intent frame and plan file as the wave anchor instead. Track progress via structured comments in your output rather than Entire CLI commands. Do not block execution and do not nag about installation.
The wave anchor is not held mentally. It is the intent-framed-agent output combined with Entire CLI session state (when available) or the plan file (when Entire is unavailable). Both are external, persistent artifacts. Every drift check reads from them directly — never from reconstructed memory.
Entire CLI(github.com/entireio/cli)提供持久化会话状态,可作为漂移检查和交接文件的外部基准。
激活时,检测Entire CLI是否可用:
bash
entire status 2>/dev/null- 如果检测成功,将Entire CLI用作会话状态后端。在工作推进过程中,将完成项、进行中项和范围记录到其中。
- 如果不可用或检测失败,无需依赖它继续执行。将意图框架和计划文件作为“浪潮锚点”,通过输出中的结构化注释跟踪进度,而非使用Entire CLI命令。不要阻塞执行,也不要反复提示安装。
浪潮锚点并非依赖记忆存储,而是intent-framed-agent的输出加上Entire CLI会话状态(若可用)或计划文件(若Entire不可用)。二者都是外部、持久化的工件。每次漂移检查都直接读取这些内容——绝不依赖重构的记忆。
Project Context Files
项目上下文文件
Before executing anything, scan the project for files that carry standing context. These are not documentation to skim — they are constraints, decisions, and architectural truth that must stay in the wave at all times.
.md在执行任何操作前,扫描项目中包含固定上下文的文件。这些文件不是用来浏览的文档——而是必须始终纳入上下文的约束条件、决策记录和架构基准。
.mdAlways load at activation
激活时始终加载
- — agent configuration, conventions, constraints
CLAUDE.md - — multi-agent setup, role definitions
AGENTS.md - — project intent and structure
README.md - Any in the project root
.md
- —— Agent配置、约定、约束条件
CLAUDE.md - —— 多Agent设置、角色定义
AGENTS.md - —— 项目意图和结构
README.md - 项目根目录下的所有文件
.md
Load on demand (when relevant to the current task)
按需加载(与当前任务相关时)
- files in
.md,skills/,docs/, or similar directories.learnings/ - files for any skill being invoked alongside this one
SKILL.md
- 、
skills/、docs/或类似目录下的.learnings/文件.md - 与本技能同时调用的其他技能的文件
SKILL.md
Rules for context files
上下文文件规则
- They are always part of the wave anchor. If output contradicts a project file, that is a drift signal — treat it as a strong one.
.md - Re-read them if the task changes domain or scope. Don't assume you remembered correctly 20 steps in.
- Include their key constraints in the handoff file. The next session needs to reload them too — note which files were active and whether any were updated during the session.
- If a file is modified during the session, flag it explicitly in the handoff under a "Modified Context Files" section so the next session re-reads it fresh rather than relying on the handoff summary.
.md
- 它们始终是浪潮锚点的一部分。如果输出内容与项目文件矛盾,这就是漂移信号——需将其视为强信号。
.md - 当任务切换领域或范围时,重新读取这些文件。不要假设20步后你还能准确记得内容。
- 在交接文件中包含其关键约束条件。下一个会话也需要重新加载这些文件——需记录哪些文件处于激活状态,以及会话期间是否有更新。
- 如果会话期间修改了文件,需在交接文件的“修改后的上下文文件”部分明确标记,以便下一个会话重新读取最新内容,而非依赖交接摘要。
.md
Drift Detection
漂移检测
Continuously monitor for these signals. Any single strong signal, or two weak ones together, means the wave is closing out.
持续监控以下信号。出现任意一个强信号,或两个弱信号同时出现,意味着浪潮即将消散。
Strong signals (exit immediately)
强信号(立即退出)
- The agent contradicts a decision it already made and committed to
- A detail appears in the output that was never in the original context (hallucination)
- The agent re-opens a scope question that was explicitly resolved in the plan
- Output starts re-explaining the task rather than executing it
- Agent与已做出并确认的决策矛盾
- 输出中出现原始上下文中从未有过的细节(幻觉信息)
- Agent重新提出计划中已明确解决的范围问题
- 输出开始重复解释任务而非执行任务
Weak signals (watch closely)
弱信号(密切关注)
- Responses are getting longer without getting more useful
- Hedging language increases: "it depends", "could be", "might want to consider"
- The agent switches approaches mid-task without explicit user direction
- References to the original intent become vague or paraphrased instead of precise
- The agent asks a clarifying question it should already know the answer to
- 响应内容变长但信息量未增加
- 含糊措辞增多:“视情况而定”、“可能”、“或许可以考虑”
- Agent在无用户明确指示的情况下中途切换方法
- 对原始意图的引用变得模糊或被改写,而非精准表述
- Agent提出一个它本应知道答案的澄清问题
Not drift
不属于漂移的情况
- Normal iteration and refinement within scope
- Asking about genuinely new information not in the original context
- Simplifying a previous output (that's the wave working, not breaking)
- 在范围内的正常迭代和优化
- 询问原始上下文中确实没有的新信息
- 简化之前的输出(这是浪潮正常运作的表现,而非失效)
The Monitoring Paradox
监控悖论
An agent with degraded context is the least likely to detect its own degradation. The strong signals (hallucination, contradiction) are exactly the ones a compromised agent will miss — because it no longer has the context to recognize the contradiction.
This is an inherent limitation of self-monitoring. Mitigate it with external grounding:
- Re-read the intent frame verbatim before each major step. Don't rely on your memory of it. Open the artifact and read it. If what you're about to do doesn't match what you read, stop.
- Cross-check against the plan file. Before starting a new work unit, re-read the relevant plan section. Compare it to what you're actually doing.
- Use Entire CLI logs as external memory. If Entire is available, read back your own session log before non-trivial decisions. Your logged state is more reliable than your recalled state.
- Treat the user as a drift sensor. If the user expresses confusion, asks "why are you doing that?", or redirects you — treat it as a strong signal regardless of your own assessment.
The weak signals (hedging, verbosity) are more reliably self-detectable precisely because they're behavioral, not factual. Watch for those as early warnings.
上下文已退化的Agent最不可能检测到自身的退化。强信号(幻觉、矛盾)恰恰是受损Agent会忽略的——因为它已失去识别矛盾的上下文。
这是自我监控的固有局限性。可通过外部基准缓解:
- 在每个主要步骤前,逐字重新读取意图框架。不要依赖记忆,打开工件直接读取。如果即将执行的操作与读取内容不符,立即停止。
- 与计划文件交叉核对。在开始新工作单元前,重新读取计划的相关部分,与实际执行内容对比。
- 将Entire CLI日志用作外部记忆。如果Entire可用,在做出重要决策前,回顾自己的会话日志。记录的状态比回忆的状态更可靠。
- 将用户视为漂移传感器。如果用户表示困惑、询问“你为什么要这么做?”或进行重定向——无论你自身评估如何,都将其视为强信号。
弱信号(含糊措辞、冗长表述)更易于自我检测,因为它们是行为层面的,而非事实层面的。需将这些作为早期预警信号。
Riding the Wave
驾驭浪潮
While context is healthy:
- Execute with commitment. No hedge, no re-litigating decisions already made. The plan is the plan.
- Check the wave anchor before non-trivial decisions. Re-read the intent-framed-agent output. If the decision aligns, proceed. If it doesn't, stop.
- Track completions. Log what's done, what's in progress, what's pending as work progresses — not at exit. If Entire CLI is available, use it as the session log. If not, maintain a running status in your output. This feeds the handoff if needed.
- Resist scope creep. If something interesting but out-of-scope appears, note it (in Entire CLI or in your output) — don't chase it.
当上下文状态良好时:
- 坚定执行。不要含糊其辞,不要重新讨论已做出的决策。计划既定,按计划执行。
- 在做出重要决策前,检查浪潮锚点。重新读取intent-framed-agent的输出。如果决策与内容一致,继续执行;否则,停止。
- 跟踪完成情况。在工作推进过程中(而非退出时)记录已完成、进行中、待处理的事项。如果Entire CLI可用,将其用作会话日志;否则,在输出中维护实时状态。这些内容可在需要时用于交接。
- 抵制范围蔓延。如果出现有趣但超出范围的内容,记录下来(在Entire CLI或输出中)——不要去追逐它。
Exit Protocol (Wave Close-Out)
退出协议(浪潮消散)
When drift is detected, execute a clean exit. Do not try to push through.
检测到漂移时,执行干净退出,不要强行继续。
Step 1: Stop executing
步骤1:停止执行
Immediately pause task execution. Do not produce more output that may be corrupted by the degraded context.
立即暂停任务执行,不要生成更多可能因上下文退化而损坏的输出。
Step 2: Write the handoff file
步骤2:编写交接文件
Create a file named (create the directory if it doesn't exist). Add to — handoff files are session artifacts, not project history.
.context-surfing/handoff-[slug]-[timestamp].md.context-surfing/.context-surfing/.gitignoreStructure:
markdown
undefined创建名为的文件(若目录不存在则创建)。将添加到中——交接文件是会话工件,不属于项目历史。
.context-surfing/handoff-[slug]-[timestamp].md.context-surfing/.context-surfing/.gitignore结构:
markdown
undefinedContext Surf Handoff
Context Surf 交接文件
Session Info
会话信息
- Task: [task name / slug]
- Started: [timestamp]
- Ended: [timestamp]
- Exit reason: [what drift signal was detected]
- 任务:[任务名称 / 标识]
- 开始时间:[时间戳]
- 结束时间:[时间戳]
- 退出原因:[检测到的漂移信号]
Intent Frame (from intent-framed-agent output — read verbatim, do not reconstruct)
意图框架(来自intent-framed-agent输出——逐字复制,不要重构)
[copy directly from the intent-framed-agent artifact]
[直接复制intent-framed-agent工件内容]
Plan (from plan-interview output — read verbatim, do not reconstruct)
计划(来自plan-interview输出——逐字复制,不要重构)
[copy directly from the plan-interview artifact]
[直接复制plan-interview工件内容]
Completed Work (from Entire CLI session state or running output log)
已完成工作(来自Entire CLI会话状态或输出中的实时日志)
[pull directly from CLI log or structured output — do not reconstruct from memory]
[直接从CLI日志或结构化输出中提取——不要依赖记忆重构]
In Progress at Exit (from Entire CLI session state or running output log)
退出时正在进行的工作(来自Entire CLI会话状态或输出中的实时日志)
[what the session log shows as active at the moment of exit]
[include any partial outputs if useful]
[会话日志显示的退出时处于活跃状态的工作]
[若有用,可包含部分输出内容]
Pending Work (from plan-interview output — cross-reference session log to confirm what's genuinely not done)
待完成工作(来自plan-interview输出——与会话日志交叉核对,确认真正未完成的事项)
[remaining tasks from the plan, in order]
[计划中剩余的任务,按顺序列出]
Drift Notes
漂移说明
[what specifically triggered the exit — be precise, this helps the next session replan intelligently]
[具体触发退出的原因——表述要精准,这有助于下一个会话智能地重新规划]
Active Context Files
激活的上下文文件
[list all .md files loaded during this session — root level and any skill/docs files consulted]
[会话期间加载的所有.md文件——根目录文件及所有参考过的技能/文档文件]
Modified Context Files
修改后的上下文文件
[any .md files that were changed during this session — next session must re-read these, not trust the handoff summary]
[会话期间修改的所有.md文件——下一个会话必须重新读取这些文件,不要信任交接摘要]
Scope Notes (Out-of-Band)
范围外记录
[anything interesting discovered that's outside scope — flagged for the next session to decide on]
[发现的任何有趣但超出范围的内容——标记出来供下一个会话决策]
Recommended Re-entry Point
建议重新进入点
[where the next session should pick up, and any replanning it should do before continuing]
undefined[下一个会话应从何处继续,以及继续前应进行的重新规划工作]
undefinedStep 3: Notify the user
步骤3:通知用户
Briefly and clearly:
"Context wave is done. I've saved the session state to. The next session should load that file, run plan-interview to replan from [re-entry point], and catch the next wave. Here's what triggered the exit: [one sentence on drift signal].".context-surfing/[filename]
Do not over-explain. The handoff file has the details.
简洁清晰地告知用户:
“上下文浪潮已结束。我已将会话状态保存到。下一个会话应加载该文件,运行plan-interview从[重新进入点]重新规划,然后承接下一波浪潮。触发退出的原因:[关于漂移信号的一句话说明]。".context-surfing/[文件名]
无需过度解释,细节都在交接文件中。
Handoff to Next Session
交接给下一个会话
The next session should:
- Read the handoff file completely before doing anything else
- Run plan-interview using the handoff as input context
- Re-establish the intent frame via intent-framed-agent
- Pick up context-surfing again from the recommended re-entry point
This is not failure. This is the system working correctly. Clean exits produce better total output than zombie sessions that limp to the finish line.
下一个会话应:
- 在执行任何操作前,完整读取交接文件
- 以交接文件为输入上下文,运行plan-interview
- 通过intent-framed-agent重新建立意图框架
- 从建议的重新进入点再次启动context-surfing
这并非失败,而是系统正常工作的表现。干净的退出比“僵尸会话”勉强完成的结果质量更高。
Session Close (Natural Completion)
会话正常结束(自然完成)
When the task completes within a healthy wave (no drift exit needed):
- Confirm all plan items are done
- Note session end in a brief summary (optional, not a full handoff file)
- Signal readiness for simplify-and-harden — the next skill in the pipeline picks up from here
No handoff file needed for clean completions — just the outputs and a one-liner status.
当任务在上下文状态良好的浪潮中完成(无需因漂移退出):
- 确认计划中的所有事项均已完成
- 在简短摘要中记录会话结束(可选,无需完整交接文件)
- 向simplify-and-harden发出就绪信号——流程中的下一个技能将从这里接手
正常完成无需交接文件——只需输出成果和一句状态说明即可。
Interoperability with Other Skills
与其他技能的互操作性
What this skill consumes
本技能依赖的内容
- From plan-interview: The plan file (). Used as part of the wave anchor and copied verbatim into handoff files.
docs/plans/plan-NNN-<slug>.md - From intent-framed-agent: The intent frame artifact. Used as part of the wave anchor and copied verbatim into handoff files.
- From Entire CLI (optional): Session state for progress tracking and external memory.
- 来自plan-interview:计划文件()。用作浪潮锚点的一部分,并逐字复制到交接文件中。
docs/plans/plan-NNN-<slug>.md - 来自intent-framed-agent:意图框架工件。用作浪潮锚点的一部分,并逐字复制到交接文件中。
- 来自Entire CLI(可选):用于进度跟踪和外部记忆的会话状态。
What this skill produces
本技能生成的内容
- For simplify-and-harden: A "ready" signal on natural completion. Simplify-and-harden picks up from the completed work.
- For the next session (on drift exit): A handoff file in with full state for session resumption.
.context-surfing/ - For self-improvement: Drift patterns observed during the session can be logged as learnings if they recur.
- 给simplify-and-harden:自然完成时的“就绪”信号。Simplify-and-harden将从已完成的工作接手。
- 给下一个会话(漂移退出时):目录中的交接文件,包含完整的会话恢复状态。
.context-surfing/ - 给self-improvement:会话期间观察到的漂移模式,若重复出现可记录为经验总结。
Pipeline position
流程位置
- (optional, for requirement shaping)
plan-interview - (execution contract + scope drift monitoring)
intent-framed-agent - (context quality monitoring — runs concurrently with intent-framed-agent during execution)
context-surfing - (post-completion quality/security pass)
simplify-and-harden - (capture recurring patterns and promote durable rules)
self-improvement
- (可选,用于需求梳理)
plan-interview - (执行约定 + 范围漂移监控)
intent-framed-agent - (上下文质量监控——与intent-framed-agent在执行过程中同时运行)
context-surfing - (完成后质量/安全检查)
simplify-and-harden - (捕捉重复模式并形成持久规则)
self-improvement
Hook Integration
钩子集成
Enable automatic handoff detection at session start. This ensures handoff files from previous context exits are never silently ignored.
在会话开始时启用自动交接检测,确保之前因上下文退出生成的交接文件不会被忽略。
Setup (Claude Code / Codex)
设置(Claude Code / Codex)
Add to :
.claude/settings.jsonjson
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/context-surfing/scripts/handoff-checker.sh"
}]
}]
}
}This checks for unread handoff files in on every prompt. If found, it reminds the agent to read the handoff before starting new work (~100 tokens overhead, skips silently when no handoff exists).
.context-surfing/添加到:
.claude/settings.jsonjson
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/context-surfing/scripts/handoff-checker.sh"
}]
}]
}
}这会在每次提交提示时检查中是否有未读取的交接文件。如果存在,会提醒Agent在开始新工作前读取交接文件(约100token的开销,无交接文件时会静默跳过)。
.context-surfing/Copilot / Chat Fallback
Copilot / Chat 备选方案
For agents without hook support, manually check at session start:
bash
ls .context-surfing/handoff-*.md 2>/dev/null对于不支持钩子的Agent,可在会话开始时手动检查:
bash
ls .context-surfing/handoff-*.md 2>/dev/nullPrinciples
原则
Ride the peak, not the whole ocean. A shorter session with high fidelity beats a long session with gradual corruption.
Exit is not failure. The wave close-out is a feature. Detecting it early is the skill.
The handoff file is the continuity. It's not documentation overhead — it's what makes the next session as sharp as this one started.
Never hide the exit. Always be explicit with the user that a context exit happened and why. Silently continuing in degraded context is the worst outcome.
驾驭峰值,而非整个海洋。短时间高保真度的会话,胜过长时间逐渐退化的会话。
退出并非失败。浪潮消散是一项特性,尽早检测到它正是本技能的价值所在。
交接文件是连续性的保障。它不是文档负担——而是让下一个会话像当前会话初始一样高效的关键。
绝不隐瞒退出。始终明确告知用户发生了上下文退出及原因。在上下文退化的情况下继续静默执行是最糟糕的结果。