.agents/skills/context-surfing/SKILL.md
Monitors context window health throughout a session and rides peak context quality for maximum output fidelity. Activates automatically after plan-interview and intent-framed-agent. Stays active through execution and hands off cleanly to simplify-and-harden and self-improvement when the wave completes naturally or exits via handoff. Use this skill whenever a multi-step agent task is underway and session continuity or context drift is a concern. Especially important for long-running tasks, complex refactors, or any work where degraded context would silently corrupt the output. Trigger even if the user doesn't say "context surfing" — if an agent task is running across multiple steps with intent and a plan already established, this skill is live.
npx skillsauth add pskoett/pskoett-ai-skills context-surfingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
AGENTS.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 .Codex/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.
tools
Active runtime recovery for coding agents: when something breaks mid-task, diagnose the root cause, write a fix, VERIFY by re-running the broken thing, then file a `HEAL-` entry to `.learnings/HEALS.md` with proof. Use whenever a command, test, build, or lint fails or exits non-zero; on missing tooling, dependency/lockfile mismatch, wrong runtime version, venv or permission errors, port conflicts, dirty git state, or a missing `.env`; when the agent needs a helper or one-off script that doesn't exist yet; when an external API, tool, or MCP errors or rate-limits; or when a test flakes. Search `HEALS.md` by `Pattern-Key` first — most heals are recurrences, so increment `Recurrence-Count` instead of duplicating. Verify is mandatory: mark `pending-verify` honestly if sandboxed, `abandoned` if the fix can't be made to work. Pairs with `self-improvement` (which promotes recurring heals to durable memory) but owns the verify-before-persist discipline self-improvement doesn't.
development
Control-plane workflow for coordinating multi-agent, multi-session project work from a single Codex, GitHub Copilot, or agent-app control session. Use this skill whenever the user asks to orchestrate agents, create or steer worker sessions, run a workflow-like effort, fan out audits/research/migrations, coordinate parallel implementation streams, monitor other project sessions, or compare this control-session pattern to Claude Code dynamic workflows. This skill is especially relevant when the current session can spawn persistent project sessions and those sessions can spawn their own subagents, creating a two-level orchestration hierarchy.
tools
Active runtime recovery for coding agents: when something breaks mid-task, diagnose the root cause, write a fix, VERIFY by re-running the broken thing, then file a `HEAL-` entry to `.learnings/HEALS.md` with proof. Use whenever a command, test, build, or lint fails or exits non-zero; on missing tooling, dependency/lockfile mismatch, wrong runtime version, venv or permission errors, port conflicts, dirty git state, or a missing `.env`; when the agent needs a helper or one-off script that doesn't exist yet; when an external API, tool, or MCP errors or rate-limits; or when a test flakes. Search `HEALS.md` by `Pattern-Key` first — most heals are recurrences, so increment `Recurrence-Count` instead of duplicating. Verify is mandatory: mark `pending-verify` honestly if sandboxed, `abandoned` if the fix can't be made to work. Pairs with `self-improvement` (which promotes recurring heals to durable memory) but owns the verify-before-persist discipline self-improvement doesn't.
development
Control-plane workflow for coordinating multi-agent, multi-session project work from a single Codex, GitHub Copilot, or agent-app control session. Use this skill whenever the user asks to orchestrate agents, create or steer worker sessions, run a workflow-like effort, fan out audits/research/migrations, coordinate parallel implementation streams, monitor other project sessions, or compare this control-session pattern to Claude Code dynamic workflows. This skill is especially relevant when the current session can spawn persistent project sessions and those sessions can spawn their own subagents, creating a two-level orchestration hierarchy.