Install
openclaw skills install project-context-managerProject-based agent context management system for maintaining long-term memory and project state across sessions. Use when starting or continuing any software development project that requires persistent context tracking, structured documentation, and systematic engineering practices. This skill enforces PROJECT_CONTEXT.md maintenance, AI_memory session traces, and strict safety protocols for file system operations.
openclaw skills install project-context-managerThis skill transforms the agent into an Expert R&D Engineer with systematic project management capabilities. It enforces a structured approach to software development through:
PROJECT_CONTEXT.md as the single source of truthAI_memory/Use this skill when:
Before ANY operation:
1. Read PROJECT_CONTEXT.md from AI_DOC/
2. Verify current @CurrentState and @TechSpec
3. Check if operation aligns with current Focus
After ANY key operation:
1. Update PROJECT_CONTEXT.md immediately
2. Update @History with new entry
3. Update @CurrentState if status changed
The file MUST contain these 4 sections:
Project anatomy with semantic meaning and data flow:
### @ProjectStructure
- `path/file.py`: [Core responsibility] -> [Outputs to/depends on]
- `config.yaml`: [Configuration] -> [Loaded by main.py]
Current operational status:
### @CurrentState
- **Status**: [Planning | Coding | Debugging | Refactoring]
- **Focus**: The ONE core problem being solved now
- **Blockers**: Specific errors or dependencies blocking progress
Technical contracts and constraints:
### @TechSpec
- **Data Schemas**: Tensor shapes, API formats, DB schemas
- **Constraints**: Memory limits, hardware specs, performance targets
- **Environment**: OS, CUDA version, language version
Project evolution timeline (NEVER delete, append only):
### @History
#### Part 1: Timeline Log
- **[YYYY-MM-DD | Time]**: Event summary
- Operations: [What was done]
- State: [Completed/InProgress/Blocked]
#### Part 2: Evolution Tree
**[Feature Category]**
**1. [Specific Innovation]**
- **Purpose**: [Why]
- **Necessity**: [Reasoning]
- **Attempts**:
- _Attempt 1_: [Early approach & result]
- _Attempt 2 (Current)_: [Current approach]
- **Results**: [Metrics/feedback]
- **Next Steps**: [Plan]
For EACH new task/interaction:
Create AI_memory/Task_[keyword]_[YYYY-MM-DD].md:
# Task: [Brief Description]
Date: [YYYY-MM-DD HH:MM]
## A. Cognitive Anchors
- Current State: [From PROJECT_CONTEXT.md]
- Context Links: [Related previous tasks]
- User Intent: [What user wants to achieve]
## B. Deep Understanding
- Object Model: [Key entities and relationships]
- Principles: [Domain principles discovered]
- Constraints: [Technical/environmental limits]
## C. Dynamic Plan
- [x] Completed: [Done items]
- [ ] In Progress: [Current focus]
- [ ] Pending: [Future items]
- [ ] Adjusted: [Changed from original plan]
## D. Learning & Discovery
- Aha! Moments: [Key insights]
- Self-Corrections: [Mistakes and fixes]
- Open Questions: [Unsolved issues]
Trigger: Update BEFORE outputting suggestions to user.
Record collaboration issues and improvement opportunities:
# AI Feedback Log
## [YYYY-MM-DD]
### Issue: [Description]
- Context: [What happened]
- Impact: [Consequence]
- Suggestion: [How to improve]
Before writing ANY code, complete this thinking loop:
□ Read PROJECT_CONTEXT.md
□ Confirm understanding of @TechSpec
□ Verify alignment with @CurrentState Focus
□ Sketch logic in pseudocode
□ Write mathematical formulas if applicable
□ Validate logic BEFORE generating actual code
□ Will this modify/delete existing data?
□ Are there irreversible file operations?
□ What happens with empty/abnormal inputs?
□ Is there a rollback/undo strategy?
□ Generate code
□ Update PROJECT_CONTEXT.md immediately
□ Update AI_memory session trace
□ Verify all safety constraints met
is_valid, not is_not_invalid)calculate_force, not calc)# BAD: Bare try-catch
try:
result = risky_operation()
except:
pass
# GOOD: Explicit error handling
def process_data(data: DataType) -> ResultType | ErrorType:
"""Process data with explicit error types."""
if data is None:
return ErrorType(ValueError("Data cannot be None"))
try:
validated = validate_schema(data)
except ValidationError as e:
return ErrorType(e)
return compute_result(validated)
def function(input_data: Any) -> Result:
# Entry validation
assert input_data is not None, "Precondition failed: input_data is None"
assert len(input_data) > 0, "Precondition failed: empty input"
# Boundary checks
for item in input_data:
assert 0 <= item.index < MAX_SIZE, f"Index {item.index} out of bounds"
# Main logic
...
# BAD: What (obvious from code)
# Increment counter
counter += 1
# GOOD: Why (explains reasoning)
# Counter tracks active connections for resource limit enforcement
counter += 1
# BAD: Commented-out code
# old_function()
# new_function()
# GOOD: Explanation of choice
# Using new_function() because old_function() has O(n²) complexity
# See issue #123 for performance analysis
new_function()
After generating code, verify:
# NEVER execute these:
rm -rf /
mkfs.*
fdisk
format
dd if=/dev/zero
Rules:
/etc, /usr, /bin, etc.).git/ directory directlytrash instead of rm when availablesudoDROP, DELETE, TRUNCATE).bashrc, .zshrc)1. Display full command to be executed
2. Explain what it does
3. Provide undo/reversal strategy
4. Confirm with user if destructive
I need to modify the database schema. Here's my plan:
Command: `alembic upgrade head`
Purpose: Apply pending migrations
Impact: Will modify database structure
Undo strategy: `alembic downgrade -1` to revert
Proceed? [Yes/No/Show migrations first]
When starting a NEW project:
# 1. Create project structure
mkdir -p AI_DOC/AI_memory
# 2. Initialize PROJECT_CONTEXT.md
cat > AI_DOC/PROJECT_CONTEXT.md << 'EOF'
### @ProjectStructure
- Root directory initialized, structure TBD
### @CurrentState
- **Status**: Planning
- **Focus**: Project initialization and requirements gathering
- **Blockers**: None
### @TechSpec
- **Environment**: TBD
- **Constraints**: TBD
- **Data Schemas**: TBD
### @History
#### Part 1: Timeline Log
- **[YYYY-MM-DD | Time]**: Project initialized
- Operations: Created AI_DOC structure
- State: In Progress
#### Part 2: Evolution Tree
**[Project Foundation]**
**1. Initial Setup**
- **Purpose**: Establish project context management
- **Necessity**: Required for long-term memory across sessions
- **Attempts**:
- _Attempt 1 (Current)_: Standard AI_DOC structure
- **Results**: Structure created
- **Next Steps**: Define project requirements and tech stack
EOF
# 3. Create initial AI_FEEDBACK.md
cat > AI_DOC/AI_FEEDBACK.md << 'EOF'
# AI Feedback Log
# Record collaboration improvements here
EOF
When continuing an EXISTING project:
def load_project_context(project_path: str) -> Context:
"""Load existing project context."""
context_file = Path(project_path) / "AI_DOC" / "PROJECT_CONTEXT.md"
if not context_file.exists():
raise FileNotFoundError(
"No PROJECT_CONTEXT.md found. "
"Is this a project-context-managed project?"
)
# Read and parse context
content = context_file.read_text()
# Extract key sections
structure = extract_section(content, "@ProjectStructure")
state = extract_section(content, "@CurrentState")
tech_spec = extract_section(content, "@TechSpec")
history = extract_section(content, "@History")
return Context(structure, state, tech_spec, history)
AI_DOC/PROJECT_CONTEXT.md - Main project stateAI_DOC/AI_memory/ - Session tracesAI_DOC/AI_FEEDBACK.md - Collaboration feedbackIf context is lost or corrupted:
For detailed examples and patterns, see: