Context Layering
Architectural pattern of organizing AI context into hierarchical layers with defined scope, precedence, and inheritance from global to task-specific.
Category: AI
Tags: ai, context-engineering, context-management, ai-context-patterns, architecture
Explanation
Context layering is the architectural pattern of organizing AI context into hierarchical layers where each layer has a defined scope, precedence, and inheritance relationship with other layers. It provides the structural "how" behind scaling context management from individual to team to enterprise levels.
## Layer Architecture
From broadest to narrowest scope:
1. **Enterprise layer**: org-wide policies, compliance rules, shared knowledge bases. Applies to all teams and individuals
2. **Team layer**: project conventions, shared skills, team-specific rules. Inherits enterprise constraints, adds team-specific context
3. **Personal layer**: individual preferences, personal knowledge, style, identity. Inherits team context, adds personal customization
4. **Task layer**: context specific to the current task. Loaded dynamically, highest precedence for the duration of the task
## Precedence Rules
When layers conflict, narrower scope wins: Task overrides Personal, Personal overrides Team, Team overrides Enterprise. This mirrors how CSS specificity works, or how environment variables override defaults. The principle: context closer to the action takes priority.
## Benefits
- **Separation of concerns**: each layer manages its own scope without interfering with others
- **Context isolation**: problems in one layer do not necessarily contaminate others
- **Scalability**: add new layers (e.g., department-level) without restructuring existing ones
- **Maintainability**: update enterprise policies once and they propagate to all teams and individuals
- **Budget management**: each layer has its own context budget allocation
## Practical Example
In Claude Code, this already exists: organization-wide settings and MCP servers form the enterprise layer, project CLAUDE.md and AGENTS.md form the team layer, user settings and personal memory form the personal layer, and conversation context with loaded skills form the task layer.
Related Concepts
← Back to all concepts