| name | Context Sync |
| description | Scan the codebase and regenerate contexts/*.yaml to keep AI agent knowledge current. Run when starting a session or after making structural changes. |
Context Sync Skill
You (the agent) scan the codebase and regenerate contexts/ directly.
Use your own tools (list files, read package.json, write files). No script needed.
When to Sync
Before working:
- Check
Last synced date in contexts/project.yaml header
- If stale or data looks wrong, regenerate
After structural changes:
- Added/removed a workspace app or package
- Added/removed a store, view, component, route, dep, test
- Bumped version
- BMAD agents generated new artifacts in
_bmad-output/
Not needed: code edits inside existing files.
How to Sync
- Read
pnpm-workspace.yaml to know workspace layout
- List
apps/ and packages/ directories to discover all workspaces
- For each workspace with a
package.json, scan its structure
- Write compact YAML to
contexts/
- Add header:
# Auto-generated by context sync โ {YYYY-MM-DD}
Directory Structure
contexts/
โโโ project.yaml โ monorepo overview (always loaded)
โโโ tech.yaml โ monorepo-level deps only
โโโ prd.yaml โ product roadmap (from BMAD or manual)
โโโ ui/ โ apps/ui/ workspace
โ โโโ architecture.yaml โ stores, routes, views, components
โ โโโ features.yaml โ feature areas, tests
โ โโโ tech.yaml โ workspace deps + devDeps
โโโ {new-app}/ โ auto-created per workspace
โ โโโ architecture.yaml
โ โโโ features.yaml
โ โโโ tech.yaml
โโโ README.md
Root level = monorepo-wide context (identity, workspaces, rules, root deps, PRD).
Workspace dirs = per-app context (architecture, features, deps).
Context Files โ Root Level
project.yaml โ ALWAYS loaded
Scan:
- Root
package.json โ monorepo name, version, scripts
pnpm-workspace.yaml โ workspace patterns
- List
apps/ and packages/ โ discover workspaces
- For each workspace: name, version from its package.json
- Primary app key deps for the stack summary
Write: identity, workspaces list, primary_app, stack, lang, rules, commands.
Include all scripts from root package.json (dev, build, test, bmad:install, bmad:update, etc.).
Footer: comments listing all available context files.
tech.yaml โ monorepo root deps only
Scan:
- Root
package.json โ devDependencies (turbo, tsx, etc.)
- Node/pnpm version requirements
Write: root deps only. Per-workspace deps go in contexts/{app}/tech.yaml.
prd.yaml โ product planning
Source:
_bmad-output/prd.md โ if non-empty, extract as YAML block
_bmad-output/product-brief.md โ if non-empty, extract
_bmad-output/planning-artifacts/ โ check for additional planning docs
- If all empty: preserve existing manual prd.yaml
Context Files โ Per Workspace
For each app in apps/, create a contexts/{app-name}/ directory with:
{app}/architecture.yaml
Scan:
apps/{app}/package.json โ type (Electron, web, etc.)
apps/{app}/src/ โ directory structure
- Entry points (main, preload, renderer for Electron; pages, components for web)
- Stores โ list all files with sizes
- Routes โ extract from router config
- Views โ list all files/dirs with sizes
- Components โ list all files/dirs with sizes
Write: entry points, stores, routes, views, components, data flow.
{app}/features.yaml
Scan:
- Feature directories within the app (anti-detection, bmad, scrum, etc.)
- Test files in the app's test directory
- BMAD version from
_bmad/bmm/config.yaml โ bmad_version field
- BMAD agents from
_bmad/bmm/agents/ โ bmad_agents list
- BMAD outputs: list all files in
_bmad-output/ including subdirs
(planning-artifacts/, implementation-artifacts/)
Write: file lists per feature area, test files, bmad_version, bmad_agents, bmad_outputs.
{app}/tech.yaml
Scan:
apps/{app}/package.json โ dependencies + devDependencies
- Build/packaging config
Write: all deps with versions, packaging targets.
Adding a New Workspace
When a new app apps/web/ or package packages/shared/ appears:
- Sync discovers it by listing
apps/ and packages/
project.yaml lists it under workspaces
contexts/web/ directory is created
architecture.yaml, features.yaml, tech.yaml generated inside it
No config needed โ the structure follows the monorepo.
Token Budget
- project.yaml: ~500 tokens (always loaded)
- {app}/architecture.yaml: ~600 tokens each (load for the app you're working on)
- {app}/features.yaml: ~400 tokens each
- {app}/tech.yaml: ~600 tokens each
- Root tech.yaml: ~200 tokens
- prd.yaml: ~600 tokens
Rules
- Use
file: size format (e.g. kanbanStore.js: 41KB)
- YAML lists for enums, maps for key-value
- No prose โ agents parse structure, not sentences
- Header comment with sync date
- Never hardcode workspace names โ always discover from filesystem
- Root context = monorepo-wide, workspace dirs = app-specific