Architecture & Internals
Plugin system, config-driven design, subagent architecture, model tier strategy, and MCP integration.
Four-Plugin Architecture
All skills, agents, and rules are organized into four self-contained plugins.
Plugin Directory Structure
dx-aem-flow/dx/plugins/ dx-core/ 49 skills, 7 agents -- ADO/Jira workflow (any stack) dx-hub/ 4 skills -- multi-repo hub orchestration dx-aem/ 12 skills, 6 agents -- AEM full-flow lifecycle dx-automation/ 11 skills -- autonomous 24/7 agents
Plugin Contents
Each plugin contains:
plugin.jsonmanifest.mcp.jsonserver configagents/subagent definitionsskills/slash commandsrules/conventionshooks/lifecycle hooksdata/seed datashared/reusable logictemplates/scaffolding
Template Scaffolding
Templates scaffold project-level files to:
.claude/rules/— conventions (both tools).github/agents/— 25 Copilot agentsAGENTS.md— agent inventory
Install Flow
Each consumer repo runs /dx-init once. The installer reads plugin.json,
copies templates, and configures .ai/config.yaml for the repo.
Config-Driven Design
Skills read configuration at runtime -- never hardcode paths, branches, or URLs.
.ai/config.yaml Structure
project: name: Brand-Frontend type: frontend scm: base-branch: development remote: origin tracker: provider: ado # or "jira" ado: project: Customer Project repository-id: xxxxxxxx-xxxx-... jira: # when provider: jira base-url: https://myorg.atlassian.net project-key: PROJ build: command: "cd ui.frontend && npm run build:new" lint: "cd ui.frontend && npm run lintcheck" aem: author-url-qa: https://... active-markets: [gb, de, fr]
Project .ai/rules/
Highest priority. Project-specific overrides that take precedence over everything else.
config.yaml Overrides
Middle layer. Per-repo settings for branches, URLs, ADO/Jira project, build commands.
Plugin Defaults
Lowest priority. Sensible defaults shipped with each plugin. Used when no override exists.
Convention Architecture
Two layers of convention files, auto-loaded by their respective tools.
.claude/rules/
Auto-loaded by Claude Code. Concise, path-scoped rules. Claude reads these automatically when working on matching files.
# paths: ["**/*.js"] - Use ES module imports - Externalize selectors to config - No console.log in production
.claude/rules/ (dual frontmatter)
Single source for both tools. Claude Code reads paths:, Copilot CLI reads applyTo: via COPILOT_CUSTOM_INSTRUCTIONS_DIRS.
# paths: ["**/*.js"] # applyTo: "**/*.js" ## Component Structure [Rules, patterns, conventions...]
Convention Rules Catalog (15 rules)
| Rule | Plugin | Scope |
|---|---|---|
plan-format.md | dx | Implementation plan structure |
pr-review.md | dx | PR review standards (80%+ confidence) |
pr-answer.md | dx | PR reply tone and conventions |
pragmatism.md | dx | Practical question filtering |
universal-reuse-first.md | dx | Reuse existing code before creating new |
fe-javascript.md | aem | Frontend JS conventions (*.js) |
fe-styles.md | aem | SCSS/CSS patterns (*.scss, *.css) |
fe-clientlibs.md | aem | AEM clientlib organization |
be-components.md | aem | Backend component definitions (*.xml) |
be-sling-models.md | aem | Sling Model patterns (*.java) |
be-testing.md | aem | Java unit testing conventions |
naming.md | aem | Component and file naming |
accessibility.md | aem | WCAG, ARIA, semantic HTML |
audit.md | aem | Remote change audit detection |
qa-basic-auth.md | aem | QA/Stage HTTP auth handling |
Superpowers Soft-Dependency
Six skills optionally invoke superpowers methodology (brainstorming, TDD, systematic debugging, verification) with inline fallback when superpowers is not installed.
Subagent Architecture
Coordinator delegates to specialized subagents. Each runs in isolated context with the right model tier.
Coordinator Never Sees File Contents
The coordinator only receives compact summaries — file lists, status codes, and diffs. This keeps context windows small and costs low.
Isolated Contexts
Each subagent runs in its own context. Skills with context: fork are automatically
isolated — no shared state leaks between steps.
Agent Type Naming
Always use the full prefixed name: dx-core:dx-code-reviewer, NOT just
dx-code-reviewer. The short name fails with “Agent type not found”.
Fork Auto-Isolation
Skills marked with context: fork spawn a new Claude instance. The parent skill
continues after the fork completes, receiving only the summary.
Model Tier Strategy
Three tiers matched to task complexity -- use the cheapest model that can do the job well.
Opus ($$$, slower)
Deep reasoning tasks that require understanding complex interactions across files and systems.
- Implementation plans
- Code review
- Root cause analysis
Sonnet ($$, balanced)
Execution tasks that need good judgment but not maximum reasoning depth.
- Step execution
- PR review
- AEM inspection
Haiku ($, fast)
Simple lookups and searches where speed matters more than depth.
- File resolution
- Doc search
- Test running
Token Budget — Typical Full Pipeline
| Phase | ~Tokens | Model |
|---|---|---|
| Requirements (4 steps) | 50K | Sonnet |
| Planning + validation | 80K | Opus |
| Execution (5 steps) | 150K | Sonnet |
| Build | 20K | Sonnet |
| Code review | 60K | Opus |
| Commit + PR | 10K | Haiku/Sonnet |
| Total | ~370K |
With Failures
Build failures, lint errors, and retry loops can push a single story to 500K-800K tokens. The self-learning system reduces retries over time.
MCP Integration
Six MCP servers provide external tool access -- ADO, Atlassian (Jira/Confluence), Figma, axe (dx), AEM, and Chrome DevTools (aem).
dx-core MCP Servers
ADO MCP
Project-level (not in a plugin)
wit_get_work_itemrepo_create_pull_requestsearch_codepipelines_run_pipeline
Atlassian MCP
Project-level (not in a plugin)
jira_get_issuejira_searchconfluence_create_pagejira_add_comment
Figma MCP
HTTP — local Figma desktop app
get_design_contextget_screenshotget_variable_defsget_metadata
axe MCP
Docker — Deque axe accessibility engine
analyze— scan for violationsremediate— suggest fixes
dx-aem MCP Servers
AEM MCP
HTTP — live AEM JCR instance
getNodeContentscanPageComponentscreatePageupdateComponent
Chrome DevTools MCP
stdio — real browser automation
navigate_pagetake_screenshotclickevaluate_script
Deferred Tools
MCP tools are deferred — they appear by name only until explicitly loaded. Skills must call
ToolSearch to fetch the full schema before invoking any MCP tool.
Agents Summary
13 specialized agents, each matched to the right model tier for its task.
| Agent | Model | Invoked By | Purpose |
|---|---|---|---|
dx-pr-reviewer | Sonnet | /dx-pr-review | PR diff analysis |
dx-code-reviewer | Opus | /dx-step-verify | Deep code review |
dx-file-resolver | Haiku | /dx-ticket-analyze | File lookup |
dx-figma-styles | Haiku | /dx-figma-prototype | CSS conventions |
dx-figma-markup | Haiku | /dx-figma-prototype | HTML conventions |
dx-doc-searcher | Haiku | /dx-help | Doc search |
aem-inspector | Sonnet | /aem-snapshot | Dialog/page operations |
aem-page-finder | Haiku | /aem-component | Page search |
aem-editorial-guide-capture | Sonnet | /aem-editorial-guide | Browser screenshots |
aem-file-resolver | Haiku | /aem-component | Component files |
aem-fe-verifier | Sonnet | /aem-fe-verify | AEM vs Figma visual |
aem-bug-executor | Sonnet | /dx-bug-verify | Bug reproduction |
Self-Learning System
Agents improve over time by recording fix patterns and promoting successful ones to rules.
Fix Pattern Logging
Every build/lint fix is logged to .ai/learning/raw/fixes.jsonl with the error,
fix applied, and component name.
Rule Promotion
3+ successful fixes for the same pattern get promoted to .claude/rules/learned-fix-*.md
— auto-loaded on future runs.
Metrics & Retro
Run metrics logged to runs.jsonl. Bug hotspot detection per component. Weekly
retrospective aggregation.
Copilot Compatibility
Same skills available in two environments -- full plugin system and portable Copilot format.
Claude Code
Full plugin system with MCP servers, subagents, hooks, and shared libraries.
GitHub Copilot CLI
Same 76 skills auto-discovered from plugins. 25 Copilot agents with allowed-tools for auto-approval
and handoffs: for navigation.
Single Source, Dual Output
Same plugins, same marketplace, same skills. Hooks use a single hooks.json with
version: 1 read by both tools. Rules use dual frontmatter in .claude/rules/.
Agent templates in .github/agents/ are generated with Copilot-specific transforms (tool names, allowed-tools).
Hooks Architecture
Shell commands that execute in response to Claude Code lifecycle events.
Stop Guard
stop-guard.sh — prevents accidental /stop during long-running
operations. Prompts for confirmation before terminating.
Figma Screenshot Cache
PostToolUse hook on get_screenshot — auto-saves Figma screenshots to disk,
avoiding repeated MCP calls for the same design.
Figma Context Cache
PostToolUse hook on get_design_context — caches design context responses
locally so repeat lookups are instant.
Template System
Pre-built templates for spec files, work item comments (ADO/Jira), and wiki pages ensure consistent, predictable output.
Spec File Templates (7)
explain.md— developer requirementsresearch.md— codebase researchimplement.md— implementation planfigma-extract.md— design tokensfigma-gaps.md— design vs code gapsprototype/— HTML prototypedod.md— definition of done
Work Item Comment Templates (5)
dor-check— Definition of Readydod-summary— Definition of Donere-summary— requirements summarypr-review-summary— review reportshare-plan— team share format
Wiki Page Templates (2)
feature-doc— feature documentationauthoring-guide— AEM component guide
Templates ensure every output follows the same structure, making it safe to rely on AI-generated documentation.
Setup Flow
One-time initialization and ongoing maintenance commands.
/dx-init
Core setup — installs plugin templates, creates .ai/config.yaml, scaffolds
rules and instructions.
/aem-init
AEM-specific seed data — component index, file patterns, content paths, architecture docs
in .ai/project/.
/auto-init
Autonomous agent setup — ADO service hooks, pipeline configs, Lambda routing for webhook events.
/dx-doctor
Health check — validates config, checks MCP connections, verifies rules are up to date.
/dx-upgrade
Updates plugin version — re-runs template scaffolding with —force to overwrite
stale files.
/dx-adapt
Auto-detect project type, structure, and build commands. Saves .ai/project.yaml
for non-AEM projects or when /dx-init needs help detecting the stack.
/dx-eject
Eject all plugin assets into the consumer repo — copies skills, agents, rules, templates, hooks, and MCP config. Full ownership without plugin dependency.
Design Decisions
Key architectural choices and the reasoning behind them.
Four Plugins, One Repo
Four independently installable plugins in a single monorepo. Non-AEM projects only need
dx-core; multi-repo projects add dx-hub; AEM projects add dx-aem; any project wanting
24/7 autonomous agents adds dx-automation. Single repo simplifies maintenance.
Config-Driven Over Hardcoded
All project-specific values read from .ai/config.yaml at runtime. The original
skills had 50+ hardcoded values (org URLs, component paths, repo names). Replacing each with
a config lookup makes skills reusable across any project.
Direct Skill Invocation
Coordinators invoke skills directly via Skill() calls instead of routing through
an intermediary executor agent. Simpler architecture, fewer context switches, lower token cost.
Three-Layer Override System
file override > config override > plugin default. Config overrides for
quick tweaks, file overrides for deep customization, plugin defaults as sensible starting points.
Projects can also shadow entire skills.
Skill Shadowing via Platform
Relies on Claude Code built-in skill precedence (project .claude/skills/ >
plugin skills) rather than custom override logic. No custom code needed — just create a
file with the same name.
Haiku for Lookup Agents
dx-file-resolver, dx-doc-searcher, and aem-page-finder
use Haiku. These agents do simple lookups — glob files, grep docs, call MCP search. Haiku is
10x faster and cheaper than Sonnet with no quality loss.
Opus for Code Review Only
Only dx-code-reviewer uses Opus. Code review is the one task where deep reasoning
directly impacts quality (catching subtle bugs, understanding architectural implications).
Other tasks are well-served by Sonnet.
Spec Directory Convention
All per-ticket output goes to .ai/specs/<id>-<slug>/ with predictable
file names. Skills find each other’s output by convention — no data passing needed.
Self-Learning in Coordinators
Learning (run logging, fix patterns, pattern promotion) lives in coordinator skills, not leaf skills. Coordinators see the full picture — how many fixes, which heals worked. JSONL for machine data, promoted rules for proven patterns (3+ successes, 0 failures).
Scripts Stay Simple
Shell scripts for common operations, not Node.js or Python. Shared functions in
dx-common.sh eliminated 26+ copies of duplicated helper scripts. No runtime
dependencies — works everywhere Claude Code runs.
Automation as a Separate Plugin
The autonomous agent infrastructure (Lambda + ADO pipelines + AWS resources) lives in its own
dx-automation plugin, not in dx-core. Interactive skills
run when you ask and respond to you. Automation agents run 24/7 without you. They have completely
different lifecycles — separate plugin, separate install, separate operational skills.
What Makes This Different
Production-grade patterns that make this enterprise-ready.
Templates for Predictive Outcome
Every skill outputs to a structured template — explain.md, implement.md, research.md. Templates encode domain knowledge and guarantee consistent output.
Hooks to Offload LLM Usage
Shell hooks intercept tool calls before the LLM sees them. Figma screenshot hooks auto-cache assets. Pre-commit hooks validate without burning tokens.
Subagents to Protect Context
Heavy operations run in isolated subagents that return compact summaries. The coordinator’s context window stays clean. Right model for the job.
Direct Skill Invocation -- No Middleman
Coordinators invoke skills directly via Skill() calls. No intermediary agent needed. Self-healing with 3 layers: fix, heal, retry loop.
Explicit Tool Allowlists
Every agent declares exactly which tools it can use. A PR reviewer cannot run Bash. Optional tools are discovered at runtime via ToolSearch.
Convention-Based Discovery
Skills write to predictable paths: .ai/specs/<id>-<slug>/explain.md. The next skill finds its predecessor’s output by convention.
The .ai/ Folder -- Clean Separation
All AI artifacts live in .ai/ — specs, config, templates, rules, learning data. Project source stays untouched.
Config-Driven, Never Hardcoded
One config.yaml holds all project values. Same plugin codebase runs across 4 repos and 50+ potential projects without a code change.
Three-Layer Override System
Plugin defaults, .ai/rules/ domain overrides, .claude/rules/ permanent conventions. Teams customize behavior by adding a file.
Memory via Markdown -- Between Steps
Each skill writes findings to a .md file. No database, no API, no shared memory bus — just files on disk. Survives session crashes.
Subagent Memory Isolation
Subagents run in their own context window. The parent never sees the 500 files the subagent searched. Context cost doesn’t propagate upward.
Cross-Repo Intelligence
Frontend bug that needs a backend fix? The agent detects the cross-repo dependency and delegates to the correct repository’s pipeline.
Model Tier Strategy
Opus for deep code review. Sonnet for execution. Haiku for simple lookups. Cost scales with complexity, not volume.
Every AI Platform
Same skills work across 10 AI platforms — Claude Code, Copilot CLI, VS Code Chat, Codex, Cursor, Windsurf, and more. Install once, use everywhere.
The Human Behind the Machine
Every project has a me.md persona file. It defines how the AI communicates — tone,
language style, PR comment voice. Not a gimmick: PR comments read like a real teammate wrote them.
Teams codify their voice without touching agent code.
Beyond Anthropic's Official Skill Guide
- Plugin architecture — the guide has standalone skills; KAI has versioned, installable plugin packages with marketplace
- Coordinator + Direct Skill Invocation — the guide shows sequential orchestration; KAI coordinators chain skills directly via Skill() calls with self-healing
- Memory via files — the guide mentions MCP data passing; KAI uses convention-based .md files that persist across sessions
- Model tiering — the guide doesn’t address cost optimization per agent; KAI assigns Opus/Sonnet/Haiku per capability
- Persona system — not in the guide; KAI’s me.md makes AI output indistinguishable from human teammates
- Hooks for LLM offloading — the guide focuses on skill instructions; KAI uses shell hooks for deterministic work
- 24/7 autonomous agents — the guide covers interactive use; KAI runs the same skills unattended on ADO pipelines
- Multi-platform support — same 76 skills + shared marketplace work across 10 AI platforms including Claude Code, Copilot CLI, VS Code Chat, Codex, Cursor, and Windsurf
Generic by Design
Any project, any stack. AEM logic lives in its own plugin — pure frontend projects never see it.
Future-Proof
Plugin architecture with versioned marketplace. New capabilities ship as plugin updates — no migration scripts.
Enterprise-Ready
Token budgets, rate limits, audit trails, role-scoped tools, deduplication, graceful degradation.