Context Aware Coding
This skill ensures that the AI developer is always aware of the specific context of the directory they are working in, and that this context is maintained for future sessions.
When to Use
- BEFORE Coding: When user asks to implement a feature or modify code in a specific directory (e.g.,
registry/,scripts/). - AFTER Coding: When a task is completed and code changes have been applied.
Workflow
Step 1: Context Acquisition (Pre-implementation)
Before writing or editing any code:
- Global Context: Read
docs/AI_CONTEXT/ARCHITECTURE.mdanddocs/AI_CONTEXT/CONSTITUTION.mdto understand the project's core principles and data flow. - Local Context: Identify the target directory for the task.
- Check for the existence of
AI_README.mdin that directory. - Action: Read the
AI_README.mdcontent. - Reasoning: Combine the global architecture rules with local directory rules to guide your implementation.
Step 2: Documentation Maintenance (Post-implementation - Pre-Commit)
After code changes are verified:
- Review the changes you just made.
- Ask: "Did I introduce a new pattern, file structure, or important rule?"
- Action:
- If YES: Update the
AI_README.mdin that directory to reflect the new reality. Use the Standard Template below. - If NO: No action needed.
- If YES: Update the
Standard AI_README Template
When creating or updating AI_README.md, strict adherence to this structure is required:
# AI Context: [Directory Name]
## 1. Responsibility
(What is the single responsibility of this directory? What is out of scope?)
## 2. Key Files & Structure
(List key files/subdirectories and their purposes)
## 3. Rules & Constraints
(Hard rules: naming conventions, forbidden dependencies, file formats)
## 4. Patterns & Best Practices
(Soft rules: coding styles, preferred idioms, error handling patterns)
## 5. Dependencies
(Inbound: Who consumes this? Outbound: What does this depend on?)
Example Scenarios
-
User: "Add a new script to crawl Anthropic docs."
- Agent:
- Target dir:
scripts/. - Read
scripts/AI_README.md. - See rule: "Use Python 3.10+, add type hints".
- Implement script following these rules.
- (Post-task) Update
scripts/AI_README.mdto list the new script in "Key Scripts".
- Target dir:
- Agent:
-
User: "Add a new provider DeepSeek."
- Agent:
- Target dir:
registry/. - Read
registry/AI_README.md. - See rule: "Do NOT put all providers in one file".
- Create
registry/providers/deepseek.json.
- Target dir:
- Agent:
Scan to join WeChat group