/directive:getting-started-with-directivefrom directive
Explains Directive fundamentals: modules, facts, derivations, constraints, resolvers, and systems. Use for newcomers asking 'what is Directive' or needing the mental model.
Ships in directive. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill applies when the project uses @directive-run/core. If not found in package.json, suggest installing it: npm install @directive-run/core.
writing-directive-moduleswriting-directive-constraintsbuilding-directive-systemstesting-directive-codebuilding-ai-orchestratorsDirective is a constraint-driven runtime for TypeScript. Instead of imperative state management, you:
The runtime watches your facts, evaluates constraints, and dispatches requirements to resolvers automatically.
Facts (state) → Derivations (computed)
↓
Constraints (when/require) → Requirements → Resolvers (async handlers)
↓
Effects (side effects, logging, sync)
| Term | What it is | Analogy |
|---|---|---|
| Fact | A piece of observable state | Redux store field |
| Derivation | Auto-tracked computed value | Recoil selector |
| Constraint | "When X is true, require Y" declaration | Business rule |
| Requirement | A typed request emitted by a constraint | Redux action |
| Resolver | Async handler that fulfills requirements | Redux thunk |
| Effect | Fire-and-forget side effect on fact changes | useEffect |
| Module | Bundle of schema + init + derive + constraints + resolvers | Feature slice |
| System | Runtime that wires modules together | Redux store |
import { createModule, createSystem, t } from "@directive-run/core";
const counter = createModule("counter", {
schema: {
facts: {
count: t.number(),
limit: t.number(),
},
},
init: (facts) => {
facts.count = 0;
facts.limit = 10;
},
derive: {
isAtLimit: (facts) => facts.count >= facts.limit,
remaining: (facts) => facts.limit - facts.count,
},
constraints: {
enforceLimit: {
when: (facts) => facts.count > facts.limit,
require: { type: "RESET_COUNT" },
},
},
resolvers: {
resetCount: {
requirement: "RESET_COUNT",
resolve: async (req, context) => {
context.facts.count = context.facts.limit;
},
},
},
});
const system = createSystem({ module: counter });
// Read state
console.log(system.facts.count); // 0
console.log(system.derive.isAtLimit); // false
// Mutate – constraints auto-evaluate
system.facts.count = 15;
// → constraint fires → resolver resets count to limit
Need to store state? → schema + init (facts)
Need computed values from state? → derive (derivations)
Need "if X then do Y" business logic? → constraint + resolver
Need side effects (logging, sync)? → effect
Need to compose multiple features? → multi-module system
Need lifecycle hooks? → plugins
Is it a business rule (if X then Y)?
├── YES → Constraint + Resolver
│ Examples: auth redirect, data fetch, validation enforcement
│
├── NO → Does it modify facts?
│ ├── YES → Direct mutation (system.facts.x = y)
│ │ Examples: user input, button click handlers
│ │
│ └── NO → Effect
│ Examples: logging, analytics, DOM sync, external API sync
schema: {
facts: {
name: t.string(), // string
age: t.number(), // number
active: t.boolean(), // boolean
role: t.string<"admin" | "user">(), // union type
profile: t.object<{ name: string }>(), // typed object
tags: t.array<string>(), // typed array
data: t.object<Profile | null>(), // nullable
},
}
Module name: "kebab-case" → createModule("user-auth", ...)
Fact keys: camelCase → schema: { isLoggedIn: t.boolean() }
Derivation: camelCase → derive: { canEdit: ... }
Constraint: camelCase → constraints: { enforceAuth: ... }
Resolver: camelCase → resolvers: { fetchProfile: ... }
Requirement: UPPER_SNAKE_CASE → require: { type: "FETCH_PROFILE" }
All available Directive skills, grouped by use case:
Learning:
getting-started-with-directive – This skill. Fundamentals and mental modelmigrating-to-directive – Convert from Redux, Zustand, XState, MobXBuilding (Core):
writing-directive-modules – Schema, type builders, derivations, namingwriting-directive-constraints – Constraints, resolvers, error boundaries, retrybuilding-directive-systems – Multi-module, plugins, React integrationscaffolding-directive-modules – Generate module + test boilerplateBuilding (AI):
building-ai-orchestrators – Single and multi-agent orchestratorsbuilding-ai-agents – Streaming, provider adapters, cross-agent communicationhardening-ai-systems – Guardrails, budgets, PII detection, securityQuality:
testing-directive-code – createTestSystem, mockResolver, time-traveltesting-ai-systems – Mock runners, evaluations, observabilityreviewing-directive-code – Anti-pattern scanner, naming auditSupporting knowledge files loaded with this skill:
core-patterns.md – Core patterns and API referenceWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub directive-run/directive --plugin directive12 skills in this plugin
/building-ai-agentsConfigure AI provider runners (Anthropic, OpenAI, Ollama), stream tokens and structured output, and wire cross-agent communication. Use when setting up LLM provider connections, implementing token streaming, choosing between providers, or building agents that communicate results to each other./building-ai-orchestratorsCreate AI orchestration systems using createAgentOrchestrator (single agent) and createMultiAgentOrchestrator (multi-agent). Define factsSchema with t.*() builders, init state, constraints for trigger conditions, and resolvers for LLM execution. Use when building LLM-powered workflows, agent pipelines, task runners, or multi-agent coordination systems./building-directive-systemsCompose Directive modules into systems: single-module and multi-module createSystem() calls, namespaced fact/derive/event access, cross-module dependencies, initialFacts and hydration, plugins (logging, devtools, persistence, circuit breaker), React adapter hooks (useSelector, useEvent, useSystem, DirectiveProvider), and system lifecycle. Use when creating a system, connecting modules together, adding plugins, or integrating Directive with React./hardening-ai-systemsAdd guardrails (input/output validation), memory strategies, token budgets, PII detection, prompt injection prevention, and circuit breakers to AI orchestrators. Use when enforcing content policies, managing costs, preventing security vulnerabilities, adding resilience, or implementing agent memory across turns./migrating-to-directiveMigrate state management code from Redux, Zustand, XState, MobX, Recoil, or Jotai to Directive. Provides concept mapping, step-by-step migration patterns, and before/after code examples. Use when asked to migrate, convert, or port existing state management to Directive./reviewing-directive-codeReview Directive code for anti-patterns, naming violations, missing error boundaries, constraint/resolver misuse, and performance issues. Use when asked to review, audit, or improve existing Directive modules, systems, or orchestrators.