jpskill.com
🛠️ 開発・MCP コミュニティ

context-management

Set up and optimize context management for any project. Use this skill when the user says "set up context management", "optimize my CLAUDE.md", "context setup", "configure compact instructions", "set up rules", or when starting a new project and wanting best practices for long sessions, memory, compaction, and subagent delegation. Also trigger when the user mentions problems with context loss, compaction losing info, or sessions getting slow.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o context-management.zip https://jpskill.com/download/10592.zip && unzip -o context-management.zip && rm context-management.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10592.zip -OutFile "$d\context-management.zip"; Expand-Archive "$d\context-management.zip" -DestinationPath $d -Force; ri "$d\context-management.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して context-management.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → context-management フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1
📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

Context Management Setup

Automates context management best practices for Claude Code projects. Analyzes the current project and generates optimized configuration files.

When to Use

  • Starting a new project (no CLAUDE.md exists)
  • Existing project needs context optimization
  • User reports context loss after compaction
  • User wants to set up rules, memory, or subagent guidelines
  • Before a long coding session

Workflow

Step 1: Analyze the Project

Before generating anything, read the project to understand its shape:

  1. Read package.json, Cargo.toml, pyproject.toml, or equivalent to detect stack
  2. Read existing CLAUDE.md if present (will update, not overwrite)
  3. Check for .claude/rules/ directory
  4. Scan src/ structure to identify major areas (api, components, lib, tests, etc.)
  5. Check for existing tsconfig.json, .eslintrc, prettier.config for conventions
  6. Read README.md if present for project context

Collect this into a mental model of the project before proceeding.

Step 2: Generate or Update CLAUDE.md

The CLAUDE.md MUST stay under 200 lines. Use @references for details.

Structure to follow:

# [Project Name]

[1-2 sentence description from README/package.json]

## Stack
[Detected stack — language, framework, DB, key libs]

## Key Commands
[Detected from package.json scripts, Makefile, etc.]
- Dev: `[command]`
- Build: `[command]`
- Test: `[command]`
- Lint: `[command]`

## Architecture
[Brief description of src/ structure — max 5-8 lines]
- @[key-file-1] for [purpose]
- @[key-file-2] for [purpose]

## Conventions
[Detected from config files — indent, quotes, semicolons, naming]

## Context Management

### Compact Instructions
When compacting, always preserve:
- List of modified files and their purpose
- Failing tests with error messages
- Architectural decisions made this session
- Current task status and next steps

When compacting, safe to discard:
- File contents that were only read for exploration
- Search results that didn't lead anywhere
- Verbose command output already acted upon

### Subagent Guidelines
- Use Explore agent for codebase searches requiring > 3 queries
- Use background agents for running test suites
- Use Plan agent before refactors touching > 5 files
- Delegate file-heavy research to subagents to protect main context

### Rules
See .claude/rules/ for scoped coding rules.

Important: If CLAUDE.md already exists, MERGE — don't replace. Add missing sections only.

Step 3: Generate Scoped Rules

Create .claude/rules/ with rules scoped to relevant paths. Only create rules for areas that actually exist in the project.

Read references/rule-templates.md for templates per area.

Rules to consider creating (only if the area exists):

File Scope Creates when
code-style.md **/* Always — general conventions
api.md src/api/**, src/routes/api/** API routes exist
components.md src/components/**, src/lib/components/** UI components exist
testing.md **/*.test.*, **/*.spec.* Test files exist
database.md prisma/**, src/db/**, drizzle/** ORM/DB config exists

Each rule file should be 10-30 lines max. Use the templates from references.

Step 4: Initialize Memory Structure

If auto-memory is enabled, create initial memory notes:

~/.claude/projects/<project-hash>/memory/MEMORY.md

Content:

# [Project Name] Memory

## Project
- Stack: [detected]
- Key paths: [detected]

## Patterns
[Leave empty — Claude fills as it learns]

## Debugging
[Leave empty — Claude fills as issues arise]

Step 5: Summary Report

After setup, show the user a summary:

Context Management Setup Complete
==================================
CLAUDE.md:     [created/updated] (X lines)
Rules:         [N] files in .claude/rules/
Memory:        [initialized/already exists]

Files created:
  - .claude/rules/code-style.md
  - .claude/rules/[others...]

Recommendations:
  - [Any project-specific suggestions]

Important Constraints

  • CLAUDE.md must stay under 200 lines
  • Each rule file must stay under 30 lines
  • Never overwrite existing files without showing diff first
  • Detect conventions from config files, don't assume
  • If stack is unknown, ask the user before generating
  • Use @references in CLAUDE.md instead of inlining large content