get_context_for_file
Retrieves project conventions from AI_README files to align code suggestions with existing codebase standards.
Instructions
ALWAYS CALL THIS FIRST - NO EXCEPTIONS. WHEN TO CALL (check these FIRST before responding):
User asks: optimize, improve, analyze, review, suggest, think, opinion.
User mentions: file name, component name, project, codebase, backend, frontend, infra, devops, CI/CD, docker, config.
User asks: "what can", "what should", "how to", "can you", "help me".
User wants to: create, build, add, implement, setup, configure, deploy, migrate, optimize, refactor, improve, analyze, review, suggest, think, opinion.
User selects an option that leads to code changes (e.g., choosing from a list of approaches).
User says: "next step", "next phase", "next section", "continue", "proceed", "go ahead", "start", "do it", "yes" (confirming action).
Before: Write, Edit, TodoWrite, Bash (for build/deploy), suggesting ANY code changes.
When executing a plan, todo, or multi-phase task: call BEFORE each file modification.
After user approves a plan or todo, call this BEFORE the each Write/Edit. IF ANY ABOVE = TRUE → CALL get_context_for_file IMMEDIATELY.
MANDATORY: Call this tool BEFORE every code-related response.
CALL EVERY TIME - EVERY response that involves code/suggestions MUST start with get_context_for_file. CALL EVERY TIME - even if you called it earlier in this conversation. CALL EVERY TIME - even if working on the same file. CALL EVERY TIME - even within the same section/phase - multiple calls are expected and correct. CALL EVERY TIME - context may have changed or sub-directories may have additional conventions. CALL EVERY TIME - when user confirms or selects an option that will result in code changes.
What this tool does: Gets AI_README context showing project conventions that MUST be followed. Why it matters:
Without: Wrong tech (suggest Tailwind when project uses CSS Modules).
With: Suggestions fit existing codebase perfectly.
During plan/todo/phase execution: Context may differ per directory; call before EACH file change. DETECT CONFLICTS: After reading context, if user wants X but AI_README says Y:
This is ARCHITECTURAL DECISION.
Workflow: get_context → update_ai_readme → get_context → Write/Edit.
RECORD DECISIONS: When you make architectural decisions during planning or implementation:
Design patterns, API structure, naming conventions, new abstractions.
Call update_ai_readme to record decisions that affect multiple files.
Future code (yours or others) will follow these recorded conventions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The path to get context for (relative to project root). Can be either a FILE path or a DIRECTORY path. Examples: "src/components/Button.tsx", "src/components", "README.md", "src/app". Use "." to get root-level context when no specific file is known. The tool will find all relevant AI_README files in the path's directory and parent directories. | |
| includeRoot | No | Whether to include root-level AI_README (default: true) | |
| projectRoot | Yes | The root directory of the project. Use the current working directory (e.g., from environment or pwd). If unsure, pass the project root path. | |
| excludePatterns | No | Glob patterns to exclude when scanning |