AI Context Patterns Skill
Purpose
Help the ai-context-writer subagent produce docs/AI_CONTEXT/AI_CONTEXT_PATTERNS.md as a pattern and convention catalog:
- •How code is organized
- •How data and types are modelled
- •How errors, logging, and validation are handled
- •How tests and TDD are approached
This document guides other agents in writing code that fits the existing system.
Sources to Read
Before updating patterns, read (selectively):
- •
@.cursor/rules/development_practices.mdc— TDD, models, DI, validation rules - •
@.cursor/rules/environment.mdc— tooling and layout assumptions - •
@python_service/— parsing, models, server behavior - •
@src/— extension host patterns, TS types, conversion functions - •
@webview-ui/— React and Rete integration, node components - •
@tests/— how tests are structured and named - •Existing
@docs/AI_CONTEXT/AI_CONTEXT_REPOSITORY.md— overall architecture context
Prefer reading specific files that demonstrate patterns instead of every file.
Required Sections in AI_CONTEXT_PATTERNS.md
Include at least:
- •
Metadata
- •Version
- •Last Updated (ISO date)
- •Tags including
patterns,conventions - •Cross-References to repository and component-specific AI_CONTEXT docs
- •
Code Organization
- •How Python modules, TS files, and React components are grouped.
- •Naming conventions for files and directories (e.g.
parser.py,server.py,extension.ts).
- •
Type & Model Patterns
- •Pydantic models in
python_service/schema.py(NodeData, ReteNode, etc.). - •TypeScript types in
src/types.tsandwebview-ui/src/types.ts. - •Conversion patterns between Python and TS (
conversion.tsfiles).
- •Pydantic models in
- •
Error Handling & Logging
- •How
ASTParseServerreports syntax vs internal errors (codes, messages). - •How the extension logs to the Output channel and surfaces user-facing errors.
- •How the webview presents error banners and supports retries.
- •How
- •
Testing & TDD
- •Where Python tests live and typical test naming/structure.
- •Where TypeScript/React tests live (if present).
- •How to approach test-first development in this repo (high level).
- •
Dependency Injection & Validation
- •How non-deterministic dependencies are passed into functions/classes (per dev rules).
- •How Pydantic models are used for input validation instead of ad-hoc checks.
- •
Q&A Behavior Examples
- •Short Q&A style entries explaining typical workflows, for example:
- •“How do I add support for a new AST node type?”
- •“How should I propagate parse errors to the webview?”
- •Each answer should reference concrete files and functions.
- •Short Q&A style entries explaining typical workflows, for example:
Style & Constraints
- •Use Q&A style for behavior explanations where possible.
- •Provide short, real code snippets, not pseudocode, and reference actual paths.
- •Keep each example focused; do not dump large code blocks.
- •Keep the file under the content length limit; if it grows, split by topic (e.g.
patterns-testing.md,patterns-errors.md) with an index file as percontent_lengthrules.
Update Strategy
When implementation patterns evolve:
- •Sync documented patterns with what the code actually does.
- •Remove or clearly mark any deprecated patterns.
- •Add new Q&A entries for newly introduced workflows or tricky behaviors.
- •Refresh metadata and cross-references.