Skills: Context Management & Injection
Last updated: 2026-08-31
An AI without context is like a traveler without a map — no matter how capable, it will go the wrong way.
1. Context Types
(1) Project Context
Project-level information, typically auto-extracted from configuration files:
TEXT
📖 Display only
Project Context Sources
├── package.json / pyproject.toml → Tech stack, dependency versions
├── .eslintrc / ruff.toml → Code style rules
├── tsconfig.json → TypeScript configuration
├── Dockerfile / docker-compose.yml → Deployment environment
├── README.md → Project description
└── .gitignore → Exclusion rules
(2) Team Context
Team-level standards and conventions:
YAML
# .claude/team-context.yaml
team:
name: "Platform Team"
conventions:
- "Functions must not exceed 30 lines"
- "Type hints are required"
- "APIs must have Swagger documentation"
stack: "Python + FastAPI + PostgreSQL"
code_owner: "alice"
(3) Conversation Context
Accumulated information within the current conversation:
TEXT
📖 Display only
Conversation context includes:
- What the user has already said
- What the AI has already done
- Files already read
- Current task progress state
2. Context Injection Methods
(1) Auto-Injection
The platform automatically detects and injects project information:
YAML
---
name: smart-review
context:
auto_inject:
- project_config
- git_diff
- test_results
---
(2) Manual Reference
Explicitly reference context variables in prompts:
MARKDOWN
## Review Rules
The current project uses {{project.language}}, follow these rules:
- Code style: {{project.linter}} configuration
- Target Python version: {{project.python_version}}
(3) File Mounting
Load specific files as context:
YAML
context:
files:
- path: ".claude/review-rules.md"
description: "Team review rules"
- path: "docs/api-spec.yaml"
description: "API specification document"
3. Context Window Management
(1) Capacity Planning
TEXT
📖 Display only
Context window allocation strategy:
Total capacity: 200K tokens
├── System prompt: ~2K
├── Skill prompt: ~5K
├── Project context: ~10K
├── Conversation history: ~50K
├── Tool output: ~80K
└── Reserved space: ~53K
(2) Priority Trimming
When context exceeds limits, trim by priority:
| Priority | Content | Trimming Strategy |
|---|---|---|
| 🔴 Cannot trim | Skill prompts, current task | Keep |
| 🟡 Compressible | Conversation history | Keep last N turns |
| 🟢 Trimmable | Early tool output, project context | Truncate or summarize |
(3) Summarization Strategy
MARKDOWN
# Context Compression Tips
1. File contents → Keep only function signatures and key lines
2. Long output → Keep summary + key data
3. Search results → Keep only matching lines and paths
4. Conversation history → Keep decision records, discard trial-and-error process
4. Context Practice
▶ Example: Context-Aware Code Review
Alice designed a review Skill that automatically senses the project environment:
YAML
---
name: context-aware-review
context:
auto_inject:
- project_config
- git_diff
files:
- path: ".claude/team-rules.md"
---
MARKDOWN
## Adaptive Review
Automatically adjust based on project tech stack:
- Detect pyproject.toml → Review by Python standards
- Detect tsconfig.json → Review by TypeScript standards
- Detect team rules file → Prioritize team conventions
Bob said: "A good Skill isn't a one-size-fits-all checklist — it's an intelligent assistant that automatically adjusts strategy based on the environment."
❓ FAQ
Q Does too much context affect performance?
A Yes. The longer the context, the slower the response and the higher the cost. Only inject necessary information; use summaries instead of full text.
Q How to make a Skill aware of the project's tech stack?
A Use auto-inject
project_config, or require AI in the prompt to detect configuration files first before deciding the review strategy.Q Where should team convention files be placed?
A We recommend
.claude/team-rules.md or CONVENTIONS.md in the project root, making it easy for AI to discover automatically.📖 Summary
- Three context types: project, team, conversation
- Three injection methods: auto-inject, manual reference, file mounting
- Window management: capacity planning, priority trimming, summary compression
- Core principle: Only inject necessary information, avoid context bloat
📝 Exercises
- Basic (⭐): Add project context auto-injection to your Skill and observe changes in AI behavior.
- Intermediate (⭐⭐): Create a team standards file and design a Skill that references it as context.
- Advanced (⭐⭐⭐): Design a context window management strategy for a complete review of a large project under a 128K token limit.