New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

Keep Claude Code sessions productive across resets

Context Mode Skill

by mohitagw15856 · MIT license · ★ 1,395 on GitHub · updated Sep 23

Context Mode Skill cover

Keep Claude Code sessions productive across resets with output filtering, session logging, and auto-resume. Use when starting a long or complex coding session, when previous sessions lost context mid-task, or when you need Claude to…

---
name: context-mode
description: "Keep Claude Code sessions productive across resets with output filtering, session logging, and auto-resume. Use when starting a long or complex coding session, when previous sessions lost context mid-task, or when you need Claude to resume exactly where it left off after a reset. Produces a session.log at the project root, filtered command output that preserves context, and automatic resume of in-progress tasks after any reset."
---

# Context Mode Skill

Fix the two session killers that end most Claude Code sessions in under 30 minutes: context bloat from raw command output, and memory loss after a reset.

Context Mode runs three systems simultaneously to keep sessions alive:

- **Output Filtering** — strips verbose command output before it enters context
- **Session Log** — writes a running log of everything that happened
- **Auto-Resume** — reads the log on reset and picks up exactly where you left off

> **Credit:** Inspired by a skill from Nate Herk's YouTube channel — adapted and extended for this library.

---

Overview

Fix the two session killers that end most Claude Code sessions in under 30 minutes: context bloat from raw command output, and memory loss after a reset.

What you get

  • Last 10 lines of stdout
  • Any lines containingerror, warn, fail, exception, traceback, fatal (case-insensitive)
  • Exit code
  • One-line summary of what the command did
Manual install (npx, ZIP)
Claude Codenpx skills add mohitagw15856/pm-claude-skills --skill context-mode -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/mohitagw15856/pm-claude-skills/tar.gz/f6ca79348c55 \ | tar -xz -C ~/.claude/skills --strip-components=2 pm-claude-skills-f6ca79348c55/skills/context-mode
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/1957a916ec101ee220d7/context-mode.zip" -OutFile "$env:TEMP\context-mode.zip"; Expand-Archive "$env:TEMP\context-mode.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md8.5 KB
Read the files here
mohitagw15856/f6ca7931 file
SKILL.md
Show the full text257 lines

Context Mode Skill

Fix the two session killers that end most Claude Code sessions in under 30 minutes: context bloat from raw command output, and memory loss after a reset.

Context Mode runs three systems simultaneously to keep sessions alive:

  • Output Filtering — strips verbose command output before it enters context
  • Session Log — writes a running log of everything that happened
  • Auto-Resume — reads the log on reset and picks up exactly where you left off

Credit: Inspired by a skill from Nate Herk's YouTube channel — adapted and extended for this library.


Required Inputs

No inputs required. Context Mode activates on command.

Optional: user can specify a custom log file path if they don't want session.log in the project root.


How Context Mode Works

Part 1 — Output Filtering

The problem: every time Claude Code runs a command, the full raw output enters the context window. A single npm install can dump hundreds of lines. A test suite run? Thousands. Within 30 minutes, the context is full of noise and Claude resets.

The fix: before any command output enters context, filter it to the useful summary only.

What gets kept:

  • Last 10 lines of stdout
  • Every line containing error, warn, fail, exception, traceback, or fatal (case-insensitive)
  • The exit code
  • A one-line summary of what the command did and whether it succeeded

What gets discarded:

  • Middle section of long stdout (replaced with [... N lines of output truncated ...])
  • Progress bars, download indicators, verbose install logs
  • Repeated identical lines (deduplicated)

Filtering summary format:

COMMAND: [command run]
STATUS:  [exit code — success / failed]
SUMMARY: [one sentence: what happened]
ERRORS:  [any error/warn lines — or "none"]
TAIL:    [last 10 lines of stdout]

Part 2 — Session Log

Claude maintains a running log file at [project root]/session.log. This file is written after every significant action and is the source of truth for resuming after a reset.

Session log format:

SESSION LOG
===========
Started:    [timestamp]
Branch:     [current git branch]
Directory:  [working directory]

FILES EDITED
────────────
[timestamp] [file path] — [one-line description of what changed]

COMMANDS RUN
────────────
[timestamp] [command] — [outcome: success / failed — brief reason]

TASKS IN PROGRESS
─────────────────
[ ] [Task description — what's been done so far and what's left]
[x] [Completed task]

LAST USER PROMPT
────────────────
[The most recent instruction from the user, verbatim]

LAST ACTION TAKEN
─────────────────
[What Claude did last, in one sentence]

Log update rules:

  • Write to session.log after every file edit
  • Write to session.log after every command run
  • Update "Tasks in Progress" when a task is started, progressed, or completed
  • Always overwrite "Last User Prompt" and "Last Action Taken" with the current values — don't append, replace

Part 3 — Resume on Reset

When a new Claude session starts, the first action is:

  1. Check for session.log in the project root
  2. If found, read it and announce the resume:
Resuming session.

Branch:          [branch]
Last working on: [last task in progress]
Files edited:    [list from session log]
Tasks pending:   [incomplete tasks]
Last prompt:     "[last user prompt]"

Continuing from where we left off.
  1. Continue with the next logical step — don't ask "what should I do?" — check the task list and carry on

If no session.log exists, start fresh and initialise the log.


Activation Response

When the user triggers Context Mode, respond with:

Context Mode active.

Session log initialised at: [absolute path to session.log]
Output filtering:           enabled
Auto-resume:                enabled

I'll maintain your session state across resets. Long sessions won't lose context.

Then immediately initialise session.log with the current timestamp, branch, and directory.


Output Structure

On activation
Context Mode active.
Session log initialised at: [path]
Output filtering: enabled
Auto-resume: enabled
I'll maintain your session state across resets. Long sessions won't lose context.
On command execution (filtered output format)
COMMAND: npm test
STATUS:  exit 1 — failed
SUMMARY: 47 tests passed, 3 failed in auth.test.ts
ERRORS:  Error: Expected 200, received 401 (line 84)
         Error: Token not found in response (line 112)
TAIL:
  ✓ login with valid credentials (23ms)
  ✓ logout clears session (11ms)
  ✗ refresh token after expiry
  ...
On reset / new session (resume announcement)
Resuming session.

Branch:          feature/auth-refresh
Last working on: Fixing token refresh logic in auth.service.ts
Files edited:    src/auth/auth.service.ts, src/auth/auth.test.ts
Tasks pending:   [ ] Fix failing test on line 112
                 [ ] Run full test suite once fix is applied
Last prompt:     "The refresh token test is still failing — look at the 401 handling"

Continuing from where we left off.

CLAUDE.md Installation Text

After activating Context Mode for the session, provide the user with the exact text to add to their CLAUDE.md to make it permanent across all sessions:

```
## Context Mode

Context Mode is always active in this project.

### Output Filtering
Before any command output enters context, filter it to:
- Last 10 lines of stdout
- Any lines containing: error, warn, fail, exception, traceback, fatal (case-insensitive)
- Exit code
- One-line summary of what the command did

Use this format for filtered output:
COMMAND: [command]
STATUS:  [exit code — success/failed]
SUMMARY: [one sentence]
ERRORS:  [error lines or "none"]
TAIL:    [last 10 lines]

### Session Log
Maintain a running session log at ./session.log. Write to it after every file edit and every command run. Track: files edited, commands run, tasks in progress, last user prompt, last action taken. Format defined in Context Mode skill.

### Auto-Resume
At the start of every new session, check for ./session.log. If it exists, read it and announce the resume state. Continue from the last task in progress without asking for instructions.
```

Tell the user: "Add this to your CLAUDE.md and Context Mode will be active permanently for this project — even after you close and reopen the session."


Quality Checks

  • session.log was initialised immediately on activation (not deferred)
  • Log path shown to user is the absolute path, not relative
  • Output filtering is applied on the very next command run — not just announced
  • Filtered output format includes: command, status, summary, errors, and tail — all five fields
  • Session log tracks all four categories: files edited, commands run, tasks in progress, last prompt
  • Resume announcement reads the actual log contents — not a generic template
  • On resume, Claude continues the work without prompting the user for instructions
  • CLAUDE.md installation text was offered after activation
  • Log update rule is clear: "Last User Prompt" and "Last Action Taken" replace previous values, not append

Anti-Patterns

  • Logging verbatim command output instead of a filtered summary (defeats the context savings)
  • A resume announcement from a generic template that ignores what the log actually says
  • Appending to "Last User Prompt" / "Last Action Taken" instead of replacing them (the log bloats)
  • Activating silently without offering the CLAUDE.md install, so it doesn't persist across sessions
  • On resume, asking the user what to do instead of continuing the in-progress task

Example Trigger Phrases

  • "Enable context mode"
  • "Turn on context mode for this session"
  • "Activate long session mode"
  • "I keep losing context — fix it"
  • "Set up session logging"
  • "Keep track of what you've done so you can resume after a reset"
  • "Enable output filtering to save context"
  • "Set up auto-resume so we don't lose our place"
1---
2name: context-mode
3description: "Keep Claude Code sessions productive across resets with output filtering, session logging, and auto-resume. Use when starting a long or complex coding session, when previous sessions lost context mid-task, or when you need Claude to resume exactly where it left off after a reset. Produces a session.log at the project root, filtered command output that preserves context, and automatic resume of in-progress tasks after any reset."
4---
5 
6# Context Mode Skill
7 
8Fix the two session killers that end most Claude Code sessions in under 30 minutes: context bloat from raw command output, and memory loss after a reset.
9 
10Context Mode runs three systems simultaneously to keep sessions alive:
11 
12- **Output Filtering** — strips verbose command output before it enters context
13- **Session Log** — writes a running log of everything that happened
14- **Auto-Resume** — reads the log on reset and picks up exactly where you left off
15 
16> **Credit:** Inspired by a skill from Nate Herk's YouTube channel — adapted and extended for this library.
17 
18---
19 
20## Required Inputs
21 
22No inputs required. Context Mode activates on command.
23 
24Optional: user can specify a custom log file path if they don't want `session.log` in the project root.
25 
26---
27 
28## How Context Mode Works
29 
30### Part 1 — Output Filtering
31 
32The problem: every time Claude Code runs a command, the full raw output enters the context window. A single `npm install` can dump hundreds of lines. A test suite run? Thousands. Within 30 minutes, the context is full of noise and Claude resets.
33 
34The fix: before any command output enters context, filter it to the useful summary only.
35 
36**What gets kept:**
37- Last 10 lines of stdout
38- Every line containing `error`, `warn`, `fail`, `exception`, `traceback`, or `fatal` (case-insensitive)
39- The exit code
40- A one-line summary of what the command did and whether it succeeded
41 
42**What gets discarded:**
43- Middle section of long stdout (replaced with `[... N lines of output truncated ...]`)
44- Progress bars, download indicators, verbose install logs
45- Repeated identical lines (deduplicated)
46 
47**Filtering summary format:**
48 
49```
50COMMAND: [command run]
51STATUS: [exit code — success / failed]
52SUMMARY: [one sentence: what happened]
53ERRORS: [any error/warn lines — or "none"]
54TAIL: [last 10 lines of stdout]
55```
56 
57---
58 
59### Part 2 — Session Log
60 
61Claude maintains a running log file at `[project root]/session.log`. This file is written after every significant action and is the source of truth for resuming after a reset.
62 
63**Session log format:**
64 
65```
66SESSION LOG
67===========
68Started: [timestamp]
69Branch: [current git branch]
70Directory: [working directory]
71 
72FILES EDITED
73────────────
74[timestamp] [file path] — [one-line description of what changed]
75 
76COMMANDS RUN
77────────────
78[timestamp] [command] — [outcome: success / failed — brief reason]
79 
80TASKS IN PROGRESS
81─────────────────
82[ ] [Task description — what's been done so far and what's left]
83[x] [Completed task]
84 
85LAST USER PROMPT
86────────────────
87[The most recent instruction from the user, verbatim]
88 
89LAST ACTION TAKEN
90─────────────────
91[What Claude did last, in one sentence]
92```
93 
94**Log update rules:**
95- Write to `session.log` after every file edit
96- Write to `session.log` after every command run
97- Update "Tasks in Progress" when a task is started, progressed, or completed
98- Always overwrite "Last User Prompt" and "Last Action Taken" with the current values — don't append, replace
99 
100---
101 
102### Part 3 — Resume on Reset
103 
104When a new Claude session starts, the first action is:
105 
1061. Check for `session.log` in the project root
1072. If found, read it and announce the resume:
108 
109```
110Resuming session.
111 
112Branch: [branch]
113Last working on: [last task in progress]
114Files edited: [list from session log]
115Tasks pending: [incomplete tasks]
116Last prompt: "[last user prompt]"
117 
118Continuing from where we left off.
119```
120 
1213. Continue with the next logical step — don't ask "what should I do?" — check the task list and carry on
122 
123If no `session.log` exists, start fresh and initialise the log.
124 
125---
126 
127## Activation Response
128 
129When the user triggers Context Mode, respond with:
130 
131```
132Context Mode active.
133 
134Session log initialised at: [absolute path to session.log]
135Output filtering: enabled
136Auto-resume: enabled
137 
138I'll maintain your session state across resets. Long sessions won't lose context.
139```
140 
141Then immediately initialise `session.log` with the current timestamp, branch, and directory.
142 
143---
144 
145## Output Structure
146 
147### On activation
148 
149```
150Context Mode active.
151Session log initialised at: [path]
152Output filtering: enabled
153Auto-resume: enabled
154I'll maintain your session state across resets. Long sessions won't lose context.
155```
156 
157### On command execution (filtered output format)
158 
159```
160COMMAND: npm test
161STATUS: exit 1 — failed
162SUMMARY: 47 tests passed, 3 failed in auth.test.ts
163ERRORS: Error: Expected 200, received 401 (line 84)
164 Error: Token not found in response (line 112)
165TAIL:
166 ✓ login with valid credentials (23ms)
167 ✓ logout clears session (11ms)
168 ✗ refresh token after expiry
169 ...
170```
171 
172### On reset / new session (resume announcement)
173 
174```
175Resuming session.
176 
177Branch: feature/auth-refresh
178Last working on: Fixing token refresh logic in auth.service.ts
179Files edited: src/auth/auth.service.ts, src/auth/auth.test.ts
180Tasks pending: [ ] Fix failing test on line 112
181 [ ] Run full test suite once fix is applied
182Last prompt: "The refresh token test is still failing — look at the 401 handling"
183 
184Continuing from where we left off.
185```
186 
187---
188 
189## CLAUDE.md Installation Text
190 
191After activating Context Mode for the session, provide the user with the exact text to add to their `CLAUDE.md` to make it permanent across all sessions:
192 
193````
194```
195## Context Mode
196 
197Context Mode is always active in this project.
198 
199### Output Filtering
200Before any command output enters context, filter it to:
201- Last 10 lines of stdout
202- Any lines containing: error, warn, fail, exception, traceback, fatal (case-insensitive)
203- Exit code
204- One-line summary of what the command did
205 
206Use this format for filtered output:
207COMMAND: [command]
208STATUS: [exit code — success/failed]
209SUMMARY: [one sentence]
210ERRORS: [error lines or "none"]
211TAIL: [last 10 lines]
212 
213### Session Log
214Maintain a running session log at ./session.log. Write to it after every file edit and every command run. Track: files edited, commands run, tasks in progress, last user prompt, last action taken. Format defined in Context Mode skill.
215 
216### Auto-Resume
217At the start of every new session, check for ./session.log. If it exists, read it and announce the resume state. Continue from the last task in progress without asking for instructions.
218```
219````
220 
221Tell the user: "Add this to your CLAUDE.md and Context Mode will be active permanently for this project — even after you close and reopen the session."
222 
223---
224 
225## Quality Checks
226 
227- [ ] `session.log` was initialised immediately on activation (not deferred)
228- [ ] Log path shown to user is the absolute path, not relative
229- [ ] Output filtering is applied on the very next command run — not just announced
230- [ ] Filtered output format includes: command, status, summary, errors, and tail — all five fields
231- [ ] Session log tracks all four categories: files edited, commands run, tasks in progress, last prompt
232- [ ] Resume announcement reads the actual log contents — not a generic template
233- [ ] On resume, Claude continues the work without prompting the user for instructions
234- [ ] CLAUDE.md installation text was offered after activation
235- [ ] Log update rule is clear: "Last User Prompt" and "Last Action Taken" replace previous values, not append
236 
237---
238 
239## Anti-Patterns
240 
241- Logging verbatim command output instead of a filtered summary (defeats the context savings)
242- A resume announcement from a generic template that ignores what the log actually says
243- Appending to "Last User Prompt" / "Last Action Taken" instead of replacing them (the log bloats)
244- Activating silently without offering the CLAUDE.md install, so it doesn't persist across sessions
245- On resume, asking the user what to do instead of continuing the in-progress task
246 
247## Example Trigger Phrases
248 
249- "Enable context mode"
250- "Turn on context mode for this session"
251- "Activate long session mode"
252- "I keep losing context — fix it"
253- "Set up session logging"
254- "Keep track of what you've done so you can resume after a reset"
255- "Enable output filtering to save context"
256- "Set up auto-resume so we don't lose our place"
257 
View all files on GitHub →

Details

Updated
Sep 23, 2026
License
MIT
Stars on the repo
★ 1,395
Checked
Source
mohitagw15856/pm-claude-skills ↗
Creator
mohitagw15856 · 193 listings
View creator

Made with context-mode

Context Mode Skill — Galaxy 3D — fly through all 1170 skills as a glowing constellation you orbit and click into (from the mohitagw15856/pm-claude-skills README)
Context Mode Skill — Galaxy 3D — fly through all 1170 skills as a glowing constellation you orbit and click into (from the mohitagw15856/pm-claude-skills README)

by mohitagw15856

Context Mode Skill — PM Skills Wrapped — your practice turned into a shareable, Spotify-Wrapped-style story (from the mohitagw15856/pm-claude-skills README)
Context Mode Skill — PM Skills Wrapped — your practice turned into a shareable, Spotify-Wrapped-style story (from the mohitagw15856/pm-claude-skills README)

by mohitagw15856

Similar skills

See all →
SkillResume a paused experiment/ar:ar-resume — Resume Experimentalirezarezvani/claude-skills · by alirezarezvaniResume a paused experiment. Checkout the experiment branch, read results history, continue iterating. Use when the user runs /ar:ar-resume or asks to pick up a previously started autoresearch experiment.★ 26.3k GitHub starsSkillComet Classic workflow entryComet Classic — OpenSpec + Superpowersrpamis/comet · by rpamisComet Classic workflow entry. Use when the user explicitly invokes /comet-classic, asks to start or resume Classic, or resume-probe returns auto_resume for one unambiguously recoverable active Classic change.★ 3.1k GitHub starsSkillFormat CVs for academic positions with publications, grantsAcademic CV builderParamchoudhary/ResumeSkills · by ParamchoudharyFormat CVs for academic positions with publications, grants, and teaching★ 2.4k GitHub starsPromptA prompt for reviewing resumesAct as a resume reviewerf/prompts.chat · by AxA prompt for reviewing resumes in the context of a specific job opening.New listingPromptFind 80%+ matching [job sector] roles postedCustomizable job scannerf/prompts.chat · by Scott MalinFind 80%+ matching [job sector] roles posted within the specified window (default: last 14 days)New listingPromptThis was created to help with my job search but I planMaster Skills & Experience Summary Generatorf/prompts.chat · by Scott MalinThis was created to help with my job search but I plan on using it once done. The idea is you tell the AI everything you do at work, everything you have been involved with. Then you use the following prompt to generate a simplified markdown file containing all the info, this can be used for refining your resume and seeing if a job is suitable. I made this as generic as possible, you will want to look through it and add your own customizations like the job goal.New listing

More from mohitagw15856

SkillDesign a 360-degree feedback survey or write a structured360-Degree Feedback Template Skillmohitagw15856/pm-claude-skills · by mohitagw15856Design a 360-degree feedback survey or write a structured 360 feedback report. Use when asked to build a 360 feedback process, write 360 feedback for a colleague, design a feedback survey, or produce a feedback report. Produces either a complete survey instrument with rating scales and open-ended questions, or a structured narrative feedback report with themes, strengths, and development areas.★ 1.4k GitHub starsSkillDesign statistically rigorous A/B tests for product featuresA/B Test Planner Skillmohitagw15856/pm-claude-skills · by mohitagw15856Design statistically rigorous A/B tests for product features, UI changes, onboarding flows, and pricing experiments. Use when asked to set up an experiment, design an A/B test, calculate sample size, or interpret test results. Produces a complete test plan with hypothesis, variant definitions, sample size, duration estimate, guardrail metrics, and a results interpretation guide.★ 1.4k GitHub starsSkillGenerate a WCAG 2.2 accessibility audit checklistAccessibility Audit Skillmohitagw15856/pm-claude-skills · by mohitagw15856Generate a WCAG 2.2 accessibility audit checklist and remediation suggestions for any UI or design. Use when asked to audit for accessibility, check WCAG compliance, review a design for a11y issues, or create an accessibility remediation plan. Produces a prioritised checklist with pass/fail assessments and specific fixes.★ 1.4k GitHub starsSkillBuild a structured account plan for any key customerAccount Plan Skillmohitagw15856/pm-claude-skills · by mohitagw15856Build a structured account plan for any key customer or target account. Use when asked to create an account plan, key account strategy, strategic account review, or territory plan. Produces a complete account plan with relationship map, growth opportunities, risks, and 90-day action plan.★ 1.4k GitHub starsSkillOptimize an article for Answer Engine Optimization so AIAEO Optimizer Skillmohitagw15856/pm-claude-skills · by mohitagw15856Optimize an article for Answer Engine Optimization (AEO) so AI engines like ChatGPT, Perplexity, and Claude can extract, quote, and cite it. Use when asked to AEO-optimize, make content AI-readable, improve AI citation chances, or adapt an article for answer engines. Produces an AEO-optimised rewrite with question headings, 50–80 word answer capsules, a paragraph-length audit, and flagged trust signals.★ 1.4k GitHub starsSkillConduct a structured ethical review of an AI or ML featureAI Ethics Review Skillmohitagw15856/pm-claude-skills · by mohitagw15856Conduct a structured ethical review of an AI or ML feature, model, or product. Use when preparing to deploy an AI system, assessing algorithmic risk, auditing a model for bias, or producing a responsible AI impact assessment. Produces a structured ethics review covering fairness, transparency, privacy, safety, accountability, and societal impact with a risk tier score, pre-deployment checklist, and prioritised mitigations.★ 1.4k GitHub stars