/directive:scaffolding-directive-modulesfrom directive
Generates Directive module scaffolds including schema, init, derivations, constraints, resolvers, and test files. Use when creating new modules or feature boilerplate.
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.
getting-started-with-directivewriting-directive-modulesreviewing-directive-codeAsk the user (or infer from context):
import { createModule, t } from "@directive-run/core";
// Module: {module-name}
// Purpose: {one-line description}
export const {camelCaseName} = createModule("{kebab-case-name}", {
schema: {
// State – all facts must have type builders
// {factName}: t.{type}(),
},
init: (facts) => {
// Set ALL schema keys to sensible defaults
// No async work, no side effects
},
derive: {
// Computed values – pure functions, auto-tracked
// {derivedName}: (facts) => {computation},
// Composition: {name}: (facts, derived) => derived.other && facts.x,
},
constraints: {
// Business rules: when X is true, require Y
// {constraintName}: {
// when: (facts) => {condition},
// require: { type: "REQUIREMENT_TYPE", ...payload },
// },
},
resolvers: {
// Async handlers for requirements
// {resolverName}: {
// requirement: "REQUIREMENT_TYPE",
// resolve: async (req, context) => {
// // Fulfill the requirement
// },
// },
},
});
import { describe, it, expect } from "vitest";
import { createTestSystem } from "@directive-run/core/testing";
import { {camelCaseName} } from "./{kebab-case-name}";
describe("{kebab-case-name}", () => {
function createTest() {
return createTestSystem({ module: {camelCaseName} });
}
describe("initialization", () => {
it("sets default values", () => {
const system = createTest();
// expect(system.facts.{fact}).toBe({default});
});
});
describe("derivations", () => {
it("computes {derivedName}", () => {
const system = createTest();
// system.facts.{fact} = {value};
// expect(system.derive.{derivedName}).toBe({expected});
});
});
describe("constraints + resolvers", () => {
it("triggers {requirement} when {condition}", async () => {
const system = createTest();
// system.facts.{fact} = {trigger value};
// await system.settle();
// expect(system.facts.{result}).toBe({expected});
});
});
});
What kind of module?
│
├── Simple state container (no async)
│ → schema + init + derive
│ → Skip constraints/resolvers
│ → Example: counter, feature-flags
│
├── Data-fetching module
│ → schema includes loading/error/data states
│ → Constraint triggers fetch when needed
│ → Resolver fetches with retry policy
│ → Example: dashboard-loader, auth-flow
│
├── Form/validation module
│ → schema for field values + validation state
│ → Constraints check validity rules
│ → Resolver submits form data
│ → Example: contact-form, form-wizard
│
├── Multi-module coordination
│ → Multiple modules + crossModuleDeps
│ → createSystem({ modules: { a, b } })
│ → Example: multi-module, permissions
│
└── AI orchestrator module
│ → Use createAgentOrchestrator or createMultiAgentOrchestrator
│ → See building-ai-orchestrators skill
schema: {
status: t.string<"idle" | "loading" | "success" | "error">(),
data: t.object<DataType | null>(),
error: t.string<string | null>(),
},
init: (facts) => {
facts.status = "idle";
facts.data = null;
facts.error = null;
},
schema: {
resource: t.object<ResourceState<T>>(),
},
// Where ResourceState<T> = { status, data, error, lastFetched }
schema: {
isAuthenticated: t.boolean(),
user: t.object<User | null>(),
token: t.string<string | null>(),
loginError: t.string<string | null>(),
},
schema: {
items: t.array<Item>(),
page: t.number(),
pageSize: t.number(),
total: t.number(),
hasMore: t.boolean(),
},
Module variable: camelCase const userAuth = createModule(...)
Module string: kebab-case createModule("user-auth", ...)
Fact keys: camelCase isLoggedIn, userName
Derivation keys: camelCase canEdit, isAdmin
Constraint keys: camelCase enforceLogin, requireProfile
Resolver keys: camelCase fetchProfile, submitLogin
Requirement types: UPPER_SNAKE "FETCH_PROFILE", "SUBMIT_LOGIN"
Test describe: kebab-case describe("user-auth", ...)
Supporting knowledge files loaded with this skill:
core-patterns.md – Patterns and API referenceschema-types.md – Type builders and schema patternsnaming.md – Naming conventionsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
scaffolding, module-generation, boilerplate, directive-modules
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./getting-started-with-directiveUnderstand Directive fundamentals: what modules, facts, derivations, constraints, resolvers, and systems are, and how they fit together. Use when someone is new to Directive, asks 'what is Directive', wants to understand the mental model, or needs help choosing between Directive concepts./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.