
context-keeper
by royisme
SKILL.md
name: context-keeper description: Maintains project context through progressive disclosure and enforced documentation. This skill should be used when starting work on a new project to initialize context documentation, or continuously during development to maintain up-to-date project structure and coding conventions. Triggers on project initialization, file modifications, or when the agent needs to understand project architecture. version: 1.0.0 context: fork allowed-tools:
- Read
- Write
- Edit
- Glob
- Grep
- Bash
- Task
Context Keeper
Maintains project context through layered documentation and enforced synchronization.
Overview
Context Keeper implements a three-level documentation system that ensures AI agents always have accurate, up-to-date context about the codebase:
- USERAGENTS.md - Project-level: structure, conventions, and directory index
- TECH_INFO.md - Directory-level: file descriptions, dependencies, and changes
- File headers - File-level: function descriptions, parameters, and modification dates
When to Use This Skill
- Project initialization: Run
scan_project.pyto generate initial documentation - Before modifying code: Read the relevant TECH_INFO.md first
- After completing changes: Update TECH_INFO.md and file headers
- When project structure changes: Update USERAGENTS.md
Key Design Decisions
- On-demand TECH_INFO.md generation: Documentation is only created for directories where the AI actually works, avoiding unnecessary files
- Event-driven maintenance: Hooks track file modifications and automatically prompt AI to update documentation at session end
- No git commits: TECH_INFO.md files are excluded from version control (local context only)
- Full directory depth: No artificial depth limitation - documentation scales with the project
- Language: All generated content is in English for international teams
Workflow
Phase 1: Initialize Project Context
Run the scanner to generate initial documentation:
python scripts/scan_project.py <project-path>
The script will:
- Detect tech stack (TypeScript, React, Go, Python, etc.)
- Infer coding conventions based on tech stack
- Generate
USERAGENTS.mdwith project structure - Note:
TECH_INFO.mdfiles are NOT pre-generated - they are created on-demand when you work in a directory - Update
AGENTS.md/CLAUDE.mdwith enforcement instructions - (Optional) Install hooks to automatically track changes and enforce documentation updates
Use --dry-run to preview changes without modifying files.
Phase 2: On-Demand TECH_INFO.md Creation
When you start working in a directory that doesn't have TECH_INFO.md:
- Check if the directory has a
TECH_INFO.mdfile - If not, create it using the template format
- Fill in the descriptions based on your analysis of the code in that directory
The template structure:
# [Directory Name] - Technical Documentation
> **Directory purpose**: [Your analysis based on file contents]
> **Last updated**: YYYY-MM-DD
---
## 📁 File Inventory
| Filename | Description | Input | Output | Dependencies |
|----------|-------------|-------|--------|--------------|
| file1.ts | [Accurate description] | Type | Type | ./other-file |
---
## 🔄 Change Log
| Date | Change | Operator |
|------|--------|----------|
| YYYY-MM-DD | [What you changed] | context-keeper |
Phase 3: Before Any Code Modification
Before modifying any file, follow this checklist:
Pre-modification checklist:
- [ ] Read USERAGENTS.md to understand project conventions
- [ ] Read target directory's TECH_INFO.md
- [ ] Understand file dependencies from TECH_INFO.md
- [ ] Review file header comments for context
Phase 4: After Code Modification
After completing changes, update documentation:
Post-modification checklist:
- [ ] Update file header (@description, @lastModified)
- [ ] Update TECH_INFO.md file table if file added/changed
- [ ] Add change record to TECH_INFO.md
- [ ] Update USERAGENTS.md if directory structure changed
Phase 5: Automatic Enforcement (via Hooks)
When the session ends, the stop.sh hook will:
- Check which files were modified during the session
- Group them by directory
- Display a mandatory action list requiring you to update documentation
- Block session completion (in
--strictmode) until documentation is updated
This ensures documentation is never forgotten, even when using multiple skills.
Installation & Setup
1. Install Dependencies
# No external dependencies required - uses Python standard library only
python3 --version # Requires Python 3.7+
2. Initialize Documentation
# Generate initial USERAGENTS.md
python scripts/scan_project.py /path/to/your/project
# Preview without changes
python scripts/scan_project.py /path/to/your/project --dry-run
3. (Optional) Install Hooks
Configure hooks in your Claude Code settings:
{
"hooks": {
"PostToolUse": "/absolute/path/to/context-keeper/hooks/post_tool_use.sh",
"Stop": "/absolute/path/to/context-keeper/hooks/stop.sh --strict"
}
}
What the hooks do:
PostToolUse: Tracks file modifications (edit_file, write, create, delete)Stop: Displays mandatory documentation tasks before session end--strictflag (optional): Blocks session completion until docs are updated
Dependencies & Runtime
- Python 3.7+ required:
scripts/scan_project.pyuses only the Python standard library - No external packages: Safe to run in restricted environments
- Git required: For .gitignore parsing and tracking changes
Documentation Templates
TECH_INFO.md Template
See references/tech_info_template.md for the standard template.
File Header Template
/**
* @file filename.ts
* @description Function description
* @module ModuleName
* @dependencies ./dependency1, ./dependency2
* @lastModified YYYY-MM-DD
*/
USERAGENTS.md Sections
See references/useragents_template.md for the standard structure.
Coding Conventions by Tech Stack
The scanner automatically infers conventions based on detected tech stack. Common rules include:
TypeScript/JavaScript:
- Do not use
anytype - useunknownfor unknown types - All functions must have explicit return type declarations
- Use
interfacefor objects,typefor unions and complex types - Enable all strict mode checks
React:
- Use function components and Hooks only
- PascalCase for component files
- Use React.memo() for optimization
- Use useMemo/useCallback to avoid unnecessary re-renders
Go:
- Follow Go official coding standards (Effective Go)
- Always handle errors explicitly
- Use gofmt for formatting
Python:
- Follow PEP 8 coding standards
- Use type hints
- Use f-strings and pathlib
Common (all projects):
- Do not use native fetch directly - use wrapped HTTP utility
- Do not hardcode sensitive information
- All async operations must have proper error handling
Enforcement Mechanism
The skill adds mandatory instructions to AGENTS.md/CLAUDE.md:
- Pre-read requirement: Agent must read USERAGENTS.md and relevant TECH_INFO.md before any modification
- Post-update requirement: Agent must update documentation after any modification
- Structure sync: Agent must check if USERAGENTS.md needs updating after task completion
- Hook enforcement: Stop hook displays mandatory action list when files were modified
File Structure
project/
├── AGENTS.md # Contains enforcement instructions
├── USERAGENTS.md # Project-level context (auto-generated)
├── .context-keeper/
│ └── pending.txt # Tracks modified files (created by hooks)
├── src/
│ ├── TECH_INFO.md # Directory-level documentation (created on-demand)
│ ├── components/
│ │ ├── TECH_INFO.md
│ │ └── Button.tsx # With file header comments
│ └── utils/
│ ├── TECH_INFO.md
│ └── http.ts
└── .gitignore # Contains TECH_INFO.md and .context-keeper/
Notes
TECH_INFO.mdfiles are added to.gitignoreby default (local context only)USERAGENTS.mdcan be committed if desired for team sharing- The scanner can be re-run to refresh documentation
- On-demand generation means only directories you actually work in will have documentation
- Hooks ensure documentation is updated even when using multiple skills
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon