context-surfing by pskoett/pskoett-ai-skills
npx skills add https://github.com/pskoett/pskoett-ai-skills --skill context-surfingnpx skills add pskoett/pskoett-ai-skills/skills/context-surfing
智能体驾驭着峰值上下文的浪潮。当浪潮达到顶峰时,它果断执行。当检测到漂移时,它会干净利落地退出——保存状态、进行交接,让下一个会话迎接下一个浪潮。
没有冲毁,没有僵尸会话。只有经过深思熟虑的高保真执行。
将上下文想象成海浪:
本技能的任务是:只要浪潮良好就持续驾驭,在它闭合之前退出。
[plan-interview] → [intent-framed-agent] → [context-surfing ACTIVE] → [simplify-and-harden] → [self-improvement]
上下文冲浪是执行层。它封装了从意图捕获到完成后审查之间的所有工作。简化和加固以及自我改进是流水线中的后续步骤——它们在上下文冲浪完成后运行,而不是作为结束它的条件。
这两个技能在执行期间都是活跃的。它们监控不同的故障模式:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
它们是互补的,而不是冗余的。一个智能体可能在上下文质量下降时仍然完全在范围内(例如,它正在做正确的事情,但开始产生幻觉细节)。相反,范围漂移也可能在上下文质量完美的情况下发生(智能体刻意追逐一个无关的方向)。intent-framed-agent 的意图检查会与上下文冲浪的浪潮监控同时触发。
优先级规则: 如果两个技能同时触发(意图检查和漂移退出同时发生),上下文冲浪的退出优先。下降的上下文使得范围检查不可靠——先解决上下文问题,然后在下一个会话中恢复范围监控。
并非每个任务都需要所有五个技能。根据任务复杂性匹配流水线深度:
| 任务类型 | 使用的技能 |
|---|---|
| 简单任务(重命名、拼写错误修复) | 无需技能——直接执行即可 |
| 小型任务(独立的错误修复、单文件更改) | 仅使用 simplify-and-harden |
| 中型任务(已知区域的功能、多文件) | intent-framed-agent + simplify-and-harden |
| 大型任务(复杂重构、新架构、不熟悉的代码库) | 完整流水线 |
| 长时间运行的任务(多会话、高上下文压力) | 完整流水线,并将 context-surfing 作为关键技能 |
如有疑问,从轻开始。如果在任务中途发现漂移或质量问题,再添加技能。
一旦意图框架和计划确立,本技能立即激活。无需显式调用。
激活时,加载所有可用的锚点:
如果既没有意图框架也没有计划(独立模式),则使用用户的原始任务描述结合项目上下文文件作为浪潮锚点。这就足够了——该技能会优雅地降级,而不是灾难性地失败。
Entire CLI (github.com/entireio/cli) 提供持久化的会话状态,作为漂移检查和交接文件的外部真实来源。
激活时,检测 Entire:
entire status 2>/dev/null
浪潮锚点并非保存在记忆中。它是由任何可用的外部、持久化工件构建的——每次漂移检查都直接从它们读取,而不是从重建的记忆中读取。
在独立模式下,锚点较弱——用于交叉检查的工件较少——但它始终存在。一个弱的锚点总比没有锚点好。
在执行任何操作之前,扫描项目中承载固定上下文的 .md 文件。这些不是需要略读的文档——它们是必须始终保持在浪潮中的约束、决策和架构事实。
CLAUDE.md —— 智能体配置、约定、约束AGENTS.md —— 多智能体设置、角色定义README.md —— 项目意图和结构.md 文件skills/、docs/、.learnings/ 或类似目录中的 .md 文件SKILL.md 文件.md 文件相矛盾,那就是一个漂移信号——将其视为强信号。.md 文件,请在交接文件的“已修改的上下文文件”部分明确标记,以便下一个会话重新读取它,而不是依赖交接摘要。持续监控以下信号。强信号会触发立即退出——浪潮正在闭合。弱信号首先触发恢复协议——浪肩可能仍然可以驾驭。
上下文质量下降的智能体最不可能检测到自身的退化。强信号(幻觉、矛盾)恰恰是受损的智能体会错过的——因为它不再具备识别矛盾的上下文。
这是自我监控的固有局限性。通过外部基础来缓解:
弱信号(模棱两可、冗长)更可靠地可以自我检测,因为它们本质上是行为性的,而非事实性的。将这些视为早期预警。
当弱信号累积时,不要立即退出——先尝试重新锚定。如果你能重新建立基础,浪肩仍然可以驾驭。
停止产生输出。重新阅读任何可用的浪潮锚点工件:
将你当前正在做的事情与这些工件指示你应该做的事情进行比较。
恢复尝试没有硬性上限。只要每次尝试都真正解决了不确定性并且用户确认了对齐,就继续重新锚定。但是:
当上下文健康时:
当强信号触发,或恢复协议未能重新锚定时,执行干净退出。不要试图强行推进。
立即暂停任务执行。不要产生更多可能因上下文质量下降而损坏的输出。
创建一个名为 .context-surfing/handoff-[slug]-[timestamp].md 的文件(如果 .context-surfing/ 目录不存在,则创建它)。将 .context-surfing/ 添加到 .gitignore 中——交接文件是会话工件,不是项目历史。
结构:
# 上下文冲浪交接
## 会话信息
- 任务:[任务名称 / slug]
- 开始时间:[时间戳]
- 结束时间:[时间戳]
- 退出原因:[检测到的漂移信号]
## 意图框架(如果可用——逐字读取,不要重建)
[直接从 intent-framed-agent 工件复制,如果不存在则写“N/A — standalone session”]
## 计划(如果可用——逐字读取,不要重建)
[直接从 plan-interview 工件复制,如果不存在则写“N/A — standalone session”]
## 原始任务描述(独立模式备用)
[如果没有意图框架或计划,则复制用户的原始任务描述]
## 已完成的工作(来自 Entire CLI 会话状态或运行输出日志)
[直接从 CLI 日志或结构化输出中提取——不要从内存中重建]
## 退出时的进行中工作(来自 Entire CLI 会话状态或运行输出日志)
[会话日志显示在退出时刻处于活动状态的内容]
[如果有用,包括任何部分输出]
## 待处理工作(来自 plan-interview 输出——交叉引用会话日志以确认哪些确实未完成)
[计划中剩余的任务,按顺序排列]
## 漂移说明
[具体是什么触发了退出——要精确,这有助于下一个会话智能地重新规划]
## 活跃的上下文文件
[列出此会话期间加载的所有 .md 文件——根级别以及任何咨询过的技能/文档文件]
## 已修改的上下文文件
[会话期间更改的任何 .md 文件——下一个会话必须重新读取这些文件,而不是信任交接摘要]
## 范围说明(带外)
[发现的任何有趣但超出范围的内容——标记出来供下一个会话决定]
## 推荐的重新进入点
[下一个会话应该从哪里开始,以及在继续之前应该进行哪些重新规划]
简洁明了地:
“上下文浪潮已结束。我已将会话状态保存到
.context-surfing/[文件名]。下一个会话应加载该文件,运行 plan-interview 以从 [重新进入点] 重新规划,并迎接下一个浪潮。以下是触发退出的原因:[关于漂移信号的一句话]。”
不要过度解释。交接文件中有详细信息。
下一个会话应该:
这不是失败。这是系统正常工作的表现。干净的退出比蹒跚到终点的僵尸会话产生更好的总体输出。
当任务在健康的浪潮中完成时(无需漂移退出):
干净完成时不需要交接文件——只需输出和一行状态说明。
docs/plans/plan-NNN-<slug>.md)。可用时增强浪潮锚点。.context-surfing/ 中的交接文件,包含用于会话恢复的完整状态。plan-interview(可选,用于需求塑造)intent-framed-agent(执行合同 + 范围漂移监控)context-surfing(上下文质量监控——在执行期间与 intent-framed-agent 同时运行)simplify-and-harden(完成后质量/安全检查)self-improvement(捕获重复出现的模式并推广持久性规则)在会话开始时启用自动交接检测。这确保来自先前上下文退出的交接文件永远不会被静默忽略。
添加到 .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/context-surfing/scripts/handoff-checker.sh"
}]
}]
}
}
这会在每次提示时检查 .context-surfing/ 中是否有未读的交接文件。如果找到,它会提醒智能体在开始新工作之前阅读交接文件(约 100 个令牌开销,没有交接文件时静默跳过)。
对于不支持钩子的智能体,在会话开始时手动检查:
ls .context-surfing/handoff-*.md 2>/dev/null
驾驭顶峰,而非整个海洋。 一个较短但高保真的会话胜过长时间但逐渐腐化的会话。
退出不是失败。 浪潮闭合是一个特性。及早检测到它是本技能的价值所在。
交接文件是连续性。 它不是文档开销——它使得下一个会话能像这个会话开始时一样敏锐。
绝不隐藏退出。 始终向用户明确说明发生了上下文退出及其原因。在上下文质量下降的情况下静默继续是最糟糕的结果。
每周安装次数
112
仓库
GitHub 星标数
72
首次出现
12 天前
安全审计
安装于
github-copilot111
gemini-cli110
amp110
cline110
codex110
kimi-cli110
npx skills add pskoett/pskoett-ai-skills/skills/context-surfing
The 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.
Think of context like an ocean wave:
The skill's job: ride as long as the wave is good, exit before it closes out.
[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.
Both skills are live during execution. They monitor different failure modes:
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.
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) | simplify-and-harden only |
| Medium (feature in known area, multi-file) | intent-framed-agent + simplify-and-harden |
| Large (complex refactor, new architecture, unfamiliar codebase) | Full pipeline |
| Long-running (multi-session, high context pressure) | Full pipeline with context-surfing as the critical skill |
When in doubt, start light. Add skills if you notice drift or quality issues mid-task.
This skill is live the moment the intent frame and plan are established. No explicit invocation needed.
At activation, load whatever anchors are available:
If neither an intent frame nor a plan exists (standalone mode), use the user's original task description combined with project context files as the wave anchor. This is sufficient — the skill degrades gracefully, not catastrophically.
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:
entire status 2>/dev/null
The wave anchor is not held mentally. It is built from whatever external, persistent artifacts are available — every drift check reads from them directly, never from reconstructed memory.
The anchor is weaker in standalone mode — fewer artifacts to cross-check against — but it is always present. A weak anchor is better than no anchor.
Before executing anything, scan the project for .md 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.
CLAUDE.md — agent configuration, conventions, constraintsAGENTS.md — multi-agent setup, role definitionsREADME.md — project intent and structure.md in the project root.md files in skills/, docs/, .learnings/, or similar directoriesSKILL.md files for any skill being invoked alongside this one.md file, that is a drift signal — treat it as a strong one..md 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.Continuously monitor for these signals. Strong signals trigger an immediate exit — the wave is closing out. Weak signals trigger the Recovery Protocol first — the shoulder might still be rideable.
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:
The weak signals (hedging, verbosity) are more reliably self-detectable precisely because they're behavioral, not factual. Watch for those as early warnings.
When weak signals accumulate, don't exit immediately — try to re-anchor first. The shoulder of the wave is still rideable if you can re-ground.
Stop producing output. Re-read whatever wave anchor artifacts are available:
Compare what you're currently doing against what these artifacts say you should be doing.
There is no hard cap on recovery attempts. Keep re-anchoring as long as each attempt genuinely resolves the uncertainty and the user confirms alignment. However:
While context is healthy:
When a strong signal fires, or the Recovery Protocol fails to re-anchor, execute a clean exit. Do not try to push through.
Immediately pause task execution. Do not produce more output that may be corrupted by the degraded context.
Create a file named .context-surfing/handoff-[slug]-[timestamp].md (create the .context-surfing/ directory if it doesn't exist). Add .context-surfing/ to .gitignore — handoff files are session artifacts, not project history.
Structure:
# Context Surf Handoff
## Session Info
- Task: [task name / slug]
- Started: [timestamp]
- Ended: [timestamp]
- Exit reason: [what drift signal was detected]
## Intent Frame (if available — read verbatim, do not reconstruct)
[copy directly from the intent-framed-agent artifact, or "N/A — standalone session" if none exists]
## Plan (if available — read verbatim, do not reconstruct)
[copy directly from the plan-interview artifact, or "N/A — standalone session" if none exists]
## Original Task Description (standalone fallback)
[copy the user's original task description if no intent frame or plan exists]
## Completed Work (from Entire CLI session state or running output log)
[pull directly from CLI log or structured output — do not reconstruct from memory]
## In Progress at Exit (from Entire CLI session state or running output log)
[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)
[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]
## Modified Context Files
[any .md files that were changed during this session — next session must re-read these, not trust the handoff summary]
## 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]
Briefly and clearly:
"Context wave is done. I've saved the session state to
.context-surfing/[filename]. 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]."
Do not over-explain. The handoff file has the details.
The next session should:
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.
When the task completes within a healthy wave (no drift exit needed):
No handoff file needed for clean completions — just the outputs and a one-liner status.
docs/plans/plan-NNN-<slug>.md). Strengthens the wave anchor when available..context-surfing/ with full state for session resumption.plan-interview (optional, for requirement shaping)intent-framed-agent (execution contract + scope drift monitoring)context-surfing (context quality monitoring — runs concurrently with intent-framed-agent during execution)simplify-and-harden (post-completion quality/security pass)self-improvement (capture recurring patterns and promote durable rules)Enable automatic handoff detection at session start. This ensures handoff files from previous context exits are never silently ignored.
Add to .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/context-surfing/scripts/handoff-checker.sh"
}]
}]
}
}
This checks for unread handoff files in .context-surfing/ 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).
For agents without hook support, manually check at session start:
ls .context-surfing/handoff-*.md 2>/dev/null
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.
Weekly Installs
112
Repository
GitHub Stars
72
First Seen
12 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot111
gemini-cli110
amp110
cline110
codex110
kimi-cli110
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
66,200 周安装