Skip to main content
ClaudeWave
Skill963 estrellas del repoactualizado 4d ago

context-mode

Context Mode activates output filtering, session logging, and auto-resume functionality to extend Claude Code sessions beyond typical 30-minute limits caused by context bloat and memory loss. Use this skill when starting long or complex coding projects, recovering from mid-task resets, or requiring Claude to continue work at the exact previous stopping point. The skill installs a session.log file at the project root, filters verbose command output to preserve context window space, and automatically resumes incomplete tasks after any Claude reset occurs.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/mohitagw15856/pm-claude-skills /tmp/context-mode && cp -r /tmp/context-mode/plugins/pm-engineering/skills/context-mode ~/.claude/skills/context-mode
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# 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.
```

3. 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 act
ai-ethics-reviewSkill

Conduct 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.

ai-product-canvasSkill

Structure AI and ML product decisions with the rigour of any product decision. Use when building AI-powered features, evaluating LLM integrations, designing AI products, or assessing AI readiness. Produces a complete AI product canvas covering problem definition, model approach, data requirements, evaluation framework, UX design, responsible AI checklist, and launch monitoring plan.

design-handoff-briefSkill

Transform feature briefs into structured design briefs that give designers the context they need before opening Figma. Use when asked to write a design brief, create a design handoff, brief a designer on a new feature, or translate a PRD into design requirements. Produces a brief with user goal, emotional context, success criteria, constraints, edge cases, and out-of-scope boundaries.

experiment-designerSkill

Design statistically rigorous A/B tests and interpret experiment results. Use when asked to design an experiment, run an A/B test, calculate sample size, interpret test results, or assess whether an experiment was successful. Produces a complete experiment design with hypothesis, sample size, run time, success criteria, and risk flags — or a results interpretation with ship/iterate/kill recommendation.

multi-source-signal-synthesiserSkill

Synthesises user signals from multiple research sources into a unified, weighted insight brief. Use when you have data from interviews, support tickets, NPS verbatims, app reviews, or sales calls and need to reconcile contradictions, surface the underlying need behind requests, or answer 'what are users really telling us'. Produces ranked insights with confidence ratings, source weighting rationale, divergent signal analysis by user segment, and a research gap identification section.

data-analysis-standardSkill

Structure a product data analysis, metric deep-dive, funnel analysis, or cohort study. Use when asked to analyse product metrics, investigate a drop in conversion, explain a data change to stakeholders, or find the root cause of a metric movement. Produces a structured analysis with question, root cause, confidence level, and recommended action.

product-health-analysisSkill

Interpret product metrics against goals and surface actionable signals. Use when asked to analyse product health, review key metrics, investigate a performance issue, produce a health report, or assess product-market fit signals. Produces a structured health report with RAG status, trend analysis, root cause hypotheses, and prioritised actions.

retention-analysisSkill

Structure a retention analysis, churn investigation, or engagement deep-dive for any product team. Use when asked to analyse user retention, investigate churn, measure DAU/MAU, or build a retention improvement plan. Produces a retention snapshot with root cause hypotheses, aha-moment correlation, and prioritised interventions.