/directive:reviewing-directive-codefrom directive
Reviews Directive (@directive-run/core) code for anti-patterns, naming violations, missing error boundaries, constraint/resolver misuse, and performance issues.
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-modulestesting-directive-codemigrating-to-directive✓ Module name is kebab-case
✓ Schema keys are camelCase
✓ All facts have explicit type builders (t.string(), t.number(), etc.)
✓ init() sets ALL schema keys (no undefined facts)
✓ No business logic in init() – just defaults
// BAD: Missing type builder
schema: { count: 0 }
// GOOD: Explicit type builder
schema: { count: t.number() }
// BAD: Business logic in init
init: (facts) => {
facts.count = localStorage.getItem("count") ?? 0;
}
// GOOD: Use a resolver for async/side-effect init
init: (facts) => {
facts.count = 0;
}
✓ Derivations are pure functions (no side effects)
✓ No mutations inside derive functions
✓ Using derive-to-derive composition correctly (via second arg)
✓ Not duplicating fact values (derive should compute, not mirror)
// BAD: Side effect in derivation
derive: {
status: (facts) => {
console.log("computing status"); // side effect!
return facts.isReady ? "ready" : "loading";
}
}
// BAD: Mirroring a fact (useless derivation)
derive: {
currentCount: (facts) => facts.count // just use facts.count
}
// GOOD: Meaningful computation
derive: {
isOverBudget: (facts) => facts.spent > facts.budget,
budgetStatus: (facts, derived) => derived.isOverBudget ? "over" : "under",
}
✓ when() is a pure predicate (no side effects)
✓ require returns a typed requirement with UPPER_SNAKE_CASE type
✓ Async constraints have explicit deps: []
✓ Priority is set when multiple constraints may conflict
✓ No redundant constraints (check if constraint already exists)
// BAD: Side effect in when()
when: (facts) => {
analytics.track("constraint-checked"); // side effect!
return facts.count > 10;
}
// BAD: Requirement type not UPPER_SNAKE_CASE
require: { type: "fetchData" }
// GOOD:
require: { type: "FETCH_DATA" }
// BAD: Async constraint without deps
constraints: {
check: {
async: true,
when: async (facts) => await validate(facts.input),
require: { type: "HANDLE_INVALID" },
// Missing: deps: ["input"]
}
}
✓ Resolver params use (req, context) – not (req, ctx)
✓ Resolver handles errors (try/catch or error boundaries)
✓ Deduplication key set for idempotent requirements
✓ Retry policy configured for network/external calls
✓ Not doing work that belongs in a constraint or effect
// BAD: Abbreviated context parameter
resolve: async (req, ctx) => { ... }
// GOOD:
resolve: async (req, context) => { ... }
// BAD: No error handling for external calls
resolve: async (req, context) => {
const data = await fetch("/api/data");
context.facts.data = await data.json();
}
// GOOD: With retry
resolvers: {
fetchData: {
requirement: "FETCH_DATA",
retry: { attempts: 3, backoff: "exponential" },
resolve: async (req, context) => {
const data = await fetch("/api/data");
context.facts.data = await data.json();
},
}
}
// BAD: Resolver checking conditions (that's a constraint's job)
resolve: async (req, context) => {
if (context.facts.isReady) {
// do something
}
}
✓ Effects are fire-and-forget (not resolving requirements)
✓ Effects have cleanup functions for subscriptions
✓ Not mutating critical state in effects (use resolvers instead)
✓ Prev parameter used for change detection
✓ Multi-module: crossModuleDeps declared for cross-module constraints
✓ No circular dependencies between modules
✓ Plugins added at system level, not module level
✓ Single module uses { module: x }, multi uses { modules: { a, b } }
✓ Derivations don't do expensive computation on every change
✓ Constraints are not overly broad (when() triggers on minimal deps)
✓ Resolvers use deduplication keys to prevent duplicate work
✓ Batch resolvers used for N+1 scenarios
✓ Effects don't trigger cascading mutations
Module names: kebab-case ("user-auth", "shopping-cart")
Fact keys: camelCase (isLoggedIn, userName)
Derivation keys: camelCase (canEdit, totalPrice)
Constraint keys: camelCase (enforceAuth, validateInput)
Resolver keys: camelCase (fetchProfile, submitOrder)
Requirement type: UPPER_SNAKE_CASE (FETCH_PROFILE, SUBMIT_ORDER)
Event types: UPPER_SNAKE_CASE (USER_CLICKED, FORM_SUBMITTED)
When reviewing, output findings as:
## Review: [module-name]
### Issues Found
| Severity | Issue | Location |
|----------|-------|----------|
| Critical | ... | file:line |
| Major | ... | file:line |
| Minor | ... | file:line |
### Recommendations
1. ...
2. ...
Supporting knowledge files loaded with this skill:
anti-patterns.md – Full anti-pattern catalog with fixescore-patterns.md – Correct patterns to recommendnaming.md – Naming conventions referenceWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
directive, code-review, anti-patterns, constraints, resolvers
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.