home / skills / physics91 / claude-vibe / context-manager

context-manager skill

/skills/context-manager

This skill analyzes your project to configure MCP servers and agents, generates context profiles, and saves token savings estimates.

npx playbooks add skill physics91/claude-vibe --skill context-manager

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
5.5 KB
---
name: context-manager
description: |
  WHEN: Context setup, token optimization, MCP/agent configuration requests
  WHAT: Project analysis + Preset recommendation + MCP server selection + Agent activation + Config generation
  WHEN NOT: Status check only → /context-status command
---

# Context Manager Skill

## Purpose
Optimizes Claude Code's context window by interactively selecting MCP servers, Custom Agents, and Slash Commands per project and generating configuration files.

## When to Use
Activate when:
1. User requests "context setup", "context management", "token optimization"
2. `/context-setup` command is executed
3. Starting work on a new project (auto-detect and recommend)

## Workflow

### Step 1: Analyze Project
Analyze project root files to detect project type.

Analysis targets:
- `package.json` (Node.js/JavaScript)
- `requirements.txt`, `pyproject.toml` (Python)
- `go.mod` (Go)
- `Cargo.toml` (Rust)
- `pom.xml`, `build.gradle` (Java)

### Step 2: Recommend Preset
Recommend preset based on detected project type.

**AskUserQuestion:**
```
"Select a context preset for your project"
Options:
- Web Development - React/Vue/Next.js (~28k saved)
- Python Web - FastAPI/Django/Flask (~30k saved)
- Go Backend - Gin/Echo/Fiber (~28k saved)
- Rust Systems - Actix/Axum (~32k saved)
- DevOps - Docker/K8s/Terraform (~25k saved)
- Data Science - ML/AI/Data (~30k saved)
- Full Stack - Web + API + DB (~20k saved)
- Minimal - Core tools only (~45k saved)
- Custom - Select manually
```

### Step 3: Custom Configuration
If Custom is selected, choose by category.

**MCP Server Selection:**
```
AskUserQuestion: "Select MCP servers to enable"
Options:
- GitHub (PR/issue management) - ~8k tokens
- Playwright (browser automation) - ~12k tokens
- Brave Search (web search) - ~3k tokens
- Select all
multiSelect: true
```

**Agent Category Selection:**
```
AskUserQuestion: "Which agent categories do you need?"
Options:
- Frontend (React, Vue, Next.js, CSS)
- Python (FastAPI, Django, Flask, Data)
- Go/Rust (Go API, Rust Systems)
- Backend (API, DB, Security)
- DevOps (Docker, K8s, Terraform, CI/CD)
- Database (SQL, ORM, Migrations)
- Mobile (iOS, Android, Flutter)
- AI/ML (ML, DL, NLP)
multiSelect: true
```

### Step 4: Generate Config Files
Create based on selections:

1. **`.claude/context-profile.json`**: Project context settings
2. **`.claude/.mcp.json`**: MCP server settings (selected servers only)

### Step 5: Restart Instructions
MCP settings apply after session restart.

```
Setup complete!

Generated files:
- .claude/context-profile.json
- .claude/.mcp.json

Active MCP servers: github, playwright, brave-search
Active agents: react-expert, css-expert, nodejs-expert
Estimated token savings: ~28,000 tokens (14%)

Restart Claude Code to apply MCP settings.
```

## Response Templates

### Project Analysis Result
```
Project analyzed.

**Detected project type**: Web Development (React + TypeScript)
**Confidence**: 85%
**Recommended preset**: web-dev
**Estimated token savings**: ~28,000 tokens

[Present preset selection with AskUserQuestion]
```

### Setup Complete
```
Context setup complete!

**Profile**: Web Development
**Project**: G:\ai-dev\my-project

### Active MCP Servers (3/6)
- github
- playwright
- brave-search

### Active Agents (5/55)
- react-expert
- css-expert
- nodejs-expert
- frontend-optimizer
- ui-ux-designer

### Generated Files
- .claude/context-profile.json
- .claude/.mcp.json

### Estimated Token Savings
~28,000 tokens (14% saved)

Restart Claude Code to apply MCP settings.
To change settings, run `/context-setup`.
```

### Current Status (/context-status)
```
## Current Context Status

**Profile**: Web Development
**Project**: G:\ai-dev\my-project

### MCP Servers (3/6 active)
[x] github
[x] playwright
[x] brave-search
[ ] filesystem (inactive)
[ ] openrouter (inactive)
[ ] context7 (inactive)

### Agents (5/55 active)
[x] react-expert, css-expert, nodejs-expert, frontend-optimizer, ui-ux-designer

### Estimated Token Savings
~28,000 tokens
```

## Best Practices

1. **Analyze first**: Analyze project files before asking questions
2. **Provide recommendations**: Recommend appropriate preset based on analysis
3. **Keep options concise**: Keep AskUserQuestion options to 4 or fewer
4. **Show token savings**: Clearly communicate impact of each choice
5. **Restart notice**: Always mention restart required for MCP changes

## Integration

This skill integrates with:
- `SessionStart` hook: Check project profile existence and notify
- `/context-setup` command: Activate this skill
- `/context-status` command: Display current status

## Available Presets

| Preset | Description | MCP Servers | Token Savings |
|--------|-------------|-------------|---------------|
| minimal | Core tools only | None | ~45k |
| web-dev | React/Vue/Next.js | github, playwright, brave-search | ~28k |
| python-web | FastAPI/Django/Flask | github, brave-search, context7 | ~30k |
| go-backend | Gin/Echo/Fiber/Chi | github, brave-search, context7 | ~28k |
| rust-systems | Actix-web/Axum | github, brave-search, context7 | ~32k |
| devops | Docker/K8s/Terraform | github, brave-search, context7 | ~25k |
| api-dev | Backend API | github, brave-search, context7 | ~25k |
| data-science | ML/AI/Data | brave-search, context7, github | ~30k |
| full-stack | Web + API + DB | github, playwright, brave-search, context7 | ~20k |

## Notes

- Project `.claude/.mcp.json` takes precedence over global settings
- Agent enable/disable is handled via system prompt instructions
- Config files can be committed to git for team sharing

Overview

This skill automates project context setup and token optimization by analyzing repository files, recommending presets, selecting MCP servers and agents, and generating Claude Code configuration files. It streamlines activation and produces reproducible .claude config artifacts so teams can preserve and restore session context efficiently.

How this skill works

The skill scans project root files to detect language and framework indicators (package.json, pyproject.toml, go.mod, Cargo.toml, pom.xml, etc.). Based on detection it recommends a preset or lets you build a custom selection of MCP servers and agent categories, then writes .claude/context-profile.json and .claude/.mcp.json and reports estimated token savings. MCP changes apply after a session restart.

When to use it

  • When initiating context setup or token optimization for a new or existing project
  • When you run the /context-setup command
  • When you need a compact preset recommendation tailored to detected project files
  • When you want to enable/disable specific MCP servers or agent categories for a project
  • Before long interactive coding sessions to reduce context window usage

Best practices

  • Analyze project files first to ensure accurate preset recommendations
  • Prefer concise preset options; offer a custom path only when needed
  • Show token savings for each choice so users can weigh tradeoffs
  • Persist per-project .claude/.mcp.json to let the repo carry context preferences
  • Always notify users that MCP changes require restarting Claude Code

Example use cases

  • Auto-detect a React + TypeScript repo and apply the Web Development preset with github, playwright, and brave-search enabled
  • Set up a Python web project (FastAPI/Django) using the python-web preset to maximize token savings
  • Create a custom profile for a monorepo: select multiple agent categories and only the MCP servers you need
  • Generate .claude config files for team sharing so all contributors restore the same agents on session start
  • Run /context-setup before a long debugging session to reduce noise and preserve the essential context

FAQ

What files does the skill inspect to detect project type?

It checks common root files such as package.json, requirements.txt, pyproject.toml, go.mod, Cargo.toml, pom.xml, and build.gradle.

Do MCP changes apply immediately?

No. MCP server changes take effect after restarting Claude Code; the skill always reminds you to restart.