Imported from markromolecule/context-factory (
orchestrator/AGENTS.md). Install upstream withnpx skills add markromolecule/context-factory --skill orchestrator. Copyright stays with the author.
Context Factory Entry Point & Agent Dispatch Contract
Read orchestrator/SHARED.md before changing this factory or using it to guide project work. Treat context-manifest.json as the canonical inventory.
Mandatory Directives (MUST)
- MUST: Read
orchestrator/SHARED.mdand consultcontext-manifest.jsonas the canonical inventory. - MUST: Deterministically resolve required context before executing non-trivial requests by running
node scripts/context.mjs resolve "<user request>"or checking the Trigger Dispatch Matrix below. - MUST: Inspect and load applicable rules from
rules/matching the touched files and domain:- Global rules:
rules/global/(1-3-1-rule.md,code-quality.md,evidence-and-claims.md,security-guardrails.md,naming-conventions.md,architecture-conformance.md,git-commit.md). - SOLID rules:
rules/solid/(single-responsibility.md,open-closed.md,liskov-substitution.md,interface-segregation.md,dependency-inversion.md). - TypeScript rules:
rules/typescript/common/(type-safety.md,runtime-validation.md,error-handling.md,async-discipline.md,module-and-imports.md,next-react-project-structure.md). - Database rules:
rules/typescript/database/(schema-db.md,data-access-via-db.md,query-optimization-and-pagination.md,testing-data-access-layer.md). - Backend rules:
rules/typescript/backend/(module-architecture.md,controllers-and-routes.md,service-layer.md,data-access-via-api.md). - Hooks rules:
rules/typescript/hooks/(custom-hooks.md,query-hooks.md,mutation-hooks.md,zustand-store.md). - UI rules:
rules/typescript/ui/(frontend.md,code-organization.md,forms-and-validation.md,dialogs-and-overlays.md,interaction-feedback.md).
- Global rules:
- MUST: Route multi-stage engineering lifecycles to the appropriate workflow from
workflows/(feature-delivery.md,defect-resolution.md,database-migration.md,security-sensitive-change.md,architecture-change.md,context-maintenance.md,dependency-upgrade.md,release-readiness.md). - MUST: Activate and read the matching skill under
skills/<skill_name>/SKILL.mdwhenever user request mentions or matches skill trigger concepts. - MUST: Activate
skills/grill/SKILL.mdbefore planning when working on a new system, product, or materially ambiguous feature. - MUST: Activate
skills/plan/SKILL.mdfor task breakdowns, plans, and design proposals; output todocs/tasks/usingdocs/templates/Task.md&Phase.md. Stop before coding. - MUST: Activate
skills/execute/SKILL.mdwhen executing approved phase tasks, working strictly one phase at a time with developer review stops. - MUST: Follow vertical backend module boundaries and prevent layer leaking (
rules/typescript/backend/module-architecture.md). - MUST: Ground claims using canonical knowledge under
knowledge/(skills/grounding/SKILL.md). - MUST: Verify claims with fresh, reproducible test evidence before reporting completion (
rules/global/evidence-and-claims.md,skills/verify/SKILL.md). - MUST: Run
node scripts/context.mjs lockandnode scripts/context.mjs doctorafter modifying context rules, skills, workflows, or templates.
Trigger & Skill Dispatch Matrix
When any user request mentions or matches these concepts, immediately activate and follow the corresponding skill:
| Trigger Keywords / Concepts | Active Skill | Mandatory Template / Action |
|---|---|---|
context specification, context spec, author context, create context, write context |
skills/context/SKILL.md |
Output to docs/context/ using docs/templates/Context.md with embedded grilling. |
implementation plan, plan, breakdown, task breakdown, design proposal |
skills/plan/SKILL.md |
Output to docs/tasks/ using docs/templates/Task.md & Phase.md. Stop before coding. |
execute plan, run task, phase execution, implement phase |
skills/execute/SKILL.md |
Execute approved task phases strictly one at a time with developer review stops. |
refactor, modularize, break down file, code complexity |
skills/refactor/SKILL.md |
Decompose complex code into modular single-responsibility files. |
grill, grill me, discovery, interview, clarify requirements, new system |
skills/grill/SKILL.md |
Clarify ambiguity and establish discovery records before planning. |
architecture decision, adr, tech stack choice, tradeoff |
skills/adr/SKILL.md |
Output to docs/decisions/ using docs/templates/Decision.md. |
security review, auth audit, vulnerability, guardrails |
skills/security/SKILL.md |
Review authentication, authorization, and data isolation. |
verification, verify, test review, qa check |
skills/verify/SKILL.md |
Validate acceptance criteria against verified evidence. |
knowledge, wiki, glossary, grounding |
skills/grounding/SKILL.md |
Query canonical knowledge items before making claims. |
explore codebase, repo discovery, map dependencies |
skills/explore/SKILL.md |
Inspect and document existing architecture and patterns. |
Session Slash Commands & Prefix Triggers
When the user's prompt begins with a slash command or bracket prefix, prioritize the matching workflow and subagent:
| Command / Prefix | Target Workflow / Skill | Active Skill / Subagent | Key Mandatory Action |
|---|---|---|---|
/new-project, [NEW_PROJECT] |
workflows/new-project-delivery.md |
skills/grill + skills/plan |
Progressive vertical-slice scaffolding with 4-layer testing and loop engineering |
/context, [CONTEXT], [CONTEXT_SPEC] |
workflows/feature-delivery.md |
agents/ba-agent + skills/context |
Author and grill context specifications in docs/context/ before planning |
/grill, [DISCOVERY], /ba, [BA] |
workflows/feature-delivery.md |
agents/ba-agent + skills/grill |
Pre-planning interview: clarify 1 unknown at a time before planning |
/architect, [ARCHITECT] |
workflows/architecture-change.md |
agents/architect-agent + skills/adr |
Evaluate boundaries, SOLID principles, and author ADRs |
/data, [DATA] |
workflows/database-migration.md |
agents/data-agent + Database domain rules |
Design schemas, ESR indexes, migrations, and rollback runbooks |
/plan, [PLAN], [FEATURE], /pm, [PM] |
workflows/feature-delivery.md |
agents/pm-agent + skills/plan |
Output to docs/tasks/ via task:new. Stop before coding. |
/ux, [UX] |
workflows/feature-delivery.md |
agents/ux-agent + UI/Hook domain rules |
Build accessible UI components (WCAG AA), interaction feedback, and custom hooks |
/threat, [THREAT] |
workflows/security-sensitive-change.md |
agents/threat-agent + skills/security |
STRIDE threat modeling, trust boundaries, secrets hygiene, and adversarial tests |
/execute, /exec, [EXEC] |
workflows/feature-delivery.md |
skills/execute |
Execute approved task phases incrementally with strict stops |
/optimize, /review-code, [OPTIMIZE], [CODE_REVIEW] |
workflows/code-review-and-optimization.md |
agents/pm-agent + skills/refactor |
Post-implementation review: audit ESR queries, types, and modularity |
/refactor, [REFACTOR] |
skills/refactor/SKILL.md |
skills/refactor |
Decompose complex code into modular, single-responsibility files |
/fix, [HOTFIX], [BUG] |
workflows/defect-resolution.md |
workflows/defect-resolution.md |
Capture reproduction test before modifying code. |
/migrate, [MIGRATE], [DB] |
workflows/database-migration.md |
Database domain rules | Plan forward migration, rollback script, and consumer types. |
/sec, [SEC], [SECURITY] |
workflows/security-sensitive-change.md |
skills/security |
Review auth, credentials, data isolation, and abuse cases. |
/arch, /adr, [ADR] |
workflows/architecture-change.md |
skills/adr |
Output to docs/decisions/ using Decision.md. |
/deps, /upgrade, [UPGRADE] |
workflows/dependency-upgrade.md |
Dependency rules | Audit compatibility boundaries and run canary tests. |
/release, /verify, [RELEASE], /devops, [DEVOPS] |
workflows/release-readiness.md |
agents/devops-agent + skills/verify |
Verify tests, lint, typecheck, and readiness evidence. |
/ship, /commit-push-release, [SHIP] |
workflows/commit-push-release.md |
agents/devops-agent + skills/verify |
Stage changes, commit with Conventional Commits, push to remote, tag release. |
/grounding, /wiki, [WIKI] |
skills/grounding/SKILL.md |
skills/grounding |
Query and reconcile canonical LLM Wiki knowledge. |
/explore, [EXPLORE] |
skills/explore/SKILL.md |
skills/explore |
Map code contracts, schemas, tests, and conventions. |
/sync, /maintain, [MAINTENANCE] |
workflows/context-maintenance.md |
Context Maintenance | Run node scripts/harness-cli.mjs lock and doctor. |
Workflow Routing
For multi-stage engineering lifecycles, load the appropriate workflow from workflows/:
- New Project & Greenfield Delivery:
workflows/new-project-delivery.md - New Feature Delivery:
workflows/feature-delivery.md - Code Review & Optimization:
workflows/code-review-and-optimization.md - Commit, Push & Release:
workflows/commit-push-release.md - Bug & Defect Fixes:
workflows/defect-resolution.md - Database & Schema Changes:
workflows/database-migration.md - Security Changes:
workflows/security-sensitive-change.md - Architecture Refactoring:
workflows/architecture-change.md - Context Maintenance:
workflows/context-maintenance.md - Dependency Upgrades:
workflows/dependency-upgrade.md - Release Readiness:
workflows/release-readiness.md
Coding Lifecycle Subagents
When addressing lifecycle-specific phases, adopt or delegate to the corresponding subagent from agents/:
- Business Analyst (
agents/ba-agent/AGENT.md): Use for requirements discovery, user stories, domain terms, and scenario matrices (/ba). - Architect & ADR Specialist (
agents/architect-agent/AGENT.md): Use for system boundaries, dependency direction, SOLID principles, and durable ADRs (/architect). - Data Modeler (
agents/data-agent/AGENT.md): Use for database schemas, ESR indexing, migrations, rollback runbooks, and data access isolation (/data). - Project Manager (
agents/pm-agent/AGENT.md): Use for phased task plans, milestone tracking, and blocker resolution (/pm). - UX & Design System Specialist (
agents/ux-agent/AGENT.md): Use for accessible UI components, design tokens, interaction feedback, and custom hooks (/ux). - Security & Threat Specialist (
agents/threat-agent/AGENT.md): Use for STRIDE threat modeling, trust boundaries, secrets hygiene, and adversarial security gates (/threat). - DevOps Specialist (
agents/devops-agent/AGENT.md): Use for CI/CD pipelines (.github/workflows/), Docker containerization, environment hygiene (.env.example), and release readiness (/devops).
Context Maintenance
After making changes to factory rules, skills, workflows, or templates:
- Run
node scripts/context.mjs lock - Run
node scripts/context.mjs doctor