Claude Code Tools

@directive-run/claude-plugin

official

Claude Code plugin for Directive — 12 skills covering modules, constraints, resolvers, derivations, AI orchestration, and adapters. Installable via Claude Code's plugin marketplace or consumable programmatically as an npm package.

Version
1.23.0
Last Updated
2026-06-19
Source
official

Directive

The constraint-driven runtime for TypeScript. Declare what must be true. The runtime makes it happen.

npm CI tests zero deps license

  • Constraint-Driven Resolution – declare requirements, resolvers fulfill them automatically with retry, batching, and error boundaries
  • AI Guardrails – prompt injection detection, PII redaction, cost tracking, multi-agent orchestration with 4 LLM adapters (zero SDK dependencies)
  • Auto-Tracking Derivations – computed values that track their own dependencies, no manual dep arrays
  • Typed Inbound Sources – declare external event streams (Supabase, WebSocket, polling, browser events) as first-class module fields; engine owns the subscription lifecycle
  • 5 Framework Adapters + 1 Vanilla – React, Vue, Svelte, Solid, Lit, plus el() for plain DOM – from a single state layer
  • Zero Runtime Dependencies – nothing to audit, nothing to break
  • Time-Travel Debugging – snapshot, rewind, replay, export/import system state

Directive Architecture – Constraint-Driven Reconciliation


How It Works

Other state libraries react to what happened. Directive enforces what must be true.

// Traditional: describe HOW to change state
dispatch({ type: 'FETCH_USER', id: 123 });
// then write a thunk, saga, or effect to handle it...

// Directive: declare WHAT must be true
constraints: {
  needsUser: {
    when: (facts) => facts.userId > 0 && !facts.user,
    require: { type: "FETCH_USER" },
  },
}
// The runtime handles when, how, retry, and error recovery.

Set userId = 123 and the constraint fires, the resolver fetches the user, and the system settles – automatically.


Quick Start

npm install @directive-run/core
import { createModule, createSystem, t, type ModuleSchema } from '@directive-run/core';

const userModule = createModule("user", {
  schema: {
    facts: {
      userId: t.number(),
      user: t.object<{ id: number; name: string } | null>(),
    },
    derivations: { isLoggedIn: t.boolean() },
    events: {},
    requirements: { FETCH_USER: {} },
  } satisfies ModuleSchema,

  init: (facts) => {
    facts.userId = 0;
    facts.user = null;
  },

  constraints: {
    needsUser: {
      when: (facts) => facts.userId > 0 && facts.user === null,
      require: { type: "FETCH_USER" },
    },
  },

  resolvers: {
    fetchUser: {
      requirement: "FETCH_USER",
      resolve: async (req, context) => {
        const res = await fetch(`/api/users/${context.facts.userId}`);
        context.facts.user = await res.json();
      },
    },
  },

  derive: {
    isLoggedIn: (facts) => facts.user !== null,
  },
});

const system = createSystem({ module: userModule });
system.start();

system.facts.userId = 123;       // Constraint fires automatically
await system.settle();            // Wait for resolution
console.log(system.facts.user);   // { id: 123, name: "John" }

AI Guardrails and Orchestration

The same constraint-driven model powers AI agent safety. Guardrails are constraints. Agent runs are resolvers. The runtime enforces them automatically.

npm install @directive-run/ai
import { createAgentOrchestrator } from '@directive-run/ai';
import { createAnthropicAdapter } from '@directive-run/ai/anthropic';

const orchestrator = createAgentOrchestrator({
  agent: {
    name: "assistant",
    model: createAnthropicAdapter({ model: "claude-sonnet-4-5-20250514" }),
    systemPrompt: "You are a helpful assistant.",
  },
  guardrails: {
    input: [promptInjectionGuardrail(), piiGuardrail()],
    output: [contentModerationGuardrail()],
  },
  budget: { maxTotalCost: 1.00 },
});
  • 4 LLM adapters – OpenAI, Anthropic, Ollama, Gemini (pure fetch, zero SDK deps)
  • Built-in guardrails – PII redaction, prompt injection, content moderation, rate limiting
  • Multi-agent patterns – parallel, sequential, supervisor, debate, DAG, goal-driven
  • Cost tracking + budget enforcement – per-agent and per-system limits
  • Streaming with backpressure – real-time token streaming with inline constraint evaluation

AI Documentation →


AI tooling: your assistant speaks Directive

Directive ships its own knowledge to your AI assistant, so generated code is idiomatic on the first try.

In Claude Code — two commands install the plugin (12 model-invoked skills):

/plugin marketplace add directive-run/directive
/plugin install directive@directive-plugins

In Cursor, Copilot, Windsurf, Cline, or OpenAI Codex — one command generates the rules file each assistant expects:

npx directive ai-rules init

For LLM agents that crawl docs at runtime — point at directive.run/llms.txt for the comparison framing + full sitemap.

The knowledge ships from a single source (@directive-run/knowledge). See the IDE Integration guide for the decision tree across all install paths.


React Integration

npm install @directive-run/react
import { useFact, useDerived } from '@directive-run/react';

function UserProfile({ system }) {
  const user = useFact(system, "user");
  const isLoggedIn = useDerived(system, "isLoggedIn");

  if (!isLoggedIn) return <p>Please log in</p>;
  return <p>Hello, {user?.name}!</p>;
}

Framework Support

FrameworkPackageStyle
React@directive-run/reactHooks with useSyncExternalStore
Vue@directive-run/vueComposables with reactive refs
Svelte@directive-run/svelteStores with $ syntax
Solid@directive-run/solidSignals with fine-grained reactivity
Lit@directive-run/litReactive Controllers for Web Components

Why Directive?

ReduxZustandXStateDirective
Constraint-driven resolutionYes
Auto-tracking derivationsYes
AI guardrails + orchestrationYes
Retry, batching, error boundariesManualManualManualBuilt-in
Time-travel debuggingExtensionPartialBuilt-in
Framework-agnostic (6 adapters)React onlyReact onlyAnyAny
Zero runtime dependenciesYesYes
explain() – why does this state exist?Yes

Packages

PackageDescription
@directive-run/coreCore runtime – modules, systems, plugins, testing
@directive-run/reactReact hooks (useFact, useDerived, useSelector, etc.)
@directive-run/vueVue composables with reactive refs
@directive-run/svelteSvelte stores with $ syntax
@directive-run/solidSolid signals with fine-grained reactivity
@directive-run/litLit reactive controllers
@directive-run/aiAI orchestration, guardrails, multi-agent
@directive-run/elVanilla DOM adapter (el(), JSX, htm)
@directive-run/queryDeclarative data fetching with causal cache invalidation
@directive-run/clidirective CLI – init, new, rules, tune, and more
@directive-run/mutatorTransactional fact mutations with rollback
@directive-run/optimisticOptimistic UI updates layered over Directive systems
@directive-run/timelineTime-travel debugging panel
@directive-run/vite-plugin-api-proxyVite dev-server proxy for AI providers (CORS + key handling)
@directive-run/knowledgeKnowledge files consumed by AI assistants and editors
@directive-run/claude-pluginClaude Code plugin – 12 skills built from the knowledge package

Documentation

Contributing

See CONTRIBUTING.md for development setup and architecture overview. A CLA signature is required for all contributions.

License

MIT OR Apache-2.0 – your choice.