ruflo

๐Ÿ›ก๏ธ @claude-flow/guidance

/docs/setup--configuration/claude-flowguidance

Overview

@claude-flow/guidance turns CLAUDE.md into a runtime governance system with enforcement gates, cryptographic proofs, and feedback loops. Agents that normally drift after 30 minutes can now operate for days โ€” rules are enforced mechanically at every step, not remembered by the model.

7-phase pipeline: Compile โ†’ Retrieve โ†’ Enforce โ†’ Trust โ†’ Prove โ†’ Defend โ†’ Evolve

CapabilityDescription
CompileParses CLAUDE.md into typed policy bundles (constitution + task-scoped shards)
RetrieveIntent-classified shard retrieval with semantic similarity and risk filters
Enforce4 gates the model cannot bypass (destructive ops, tool allowlist, diff size, secrets)
TrustPer-agent trust accumulation with privilege tiers and coherence-driven throttling
ProveHMAC-SHA256 hash-chained proof envelopes for cryptographic run auditing
DefendPrompt injection, memory poisoning, and inter-agent collusion detection
EvolveOptimizer loop that ranks violations, simulates rule changes, and promotes winners

Install

bash
npm install @claude-flow/guidance@alpha

Quick Usage

typescript
import {
  createCompiler,
  createRetriever,
  createGates,
  createLedger,
  createProofChain,
} from '@claude-flow/guidance';

// Compile CLAUDE.md into a policy bundle
const compiler = createCompiler();
const bundle = await compiler.compile(claudeMdText);

// Retrieve task-relevant rules
const retriever = createRetriever();
await retriever.loadBundle(bundle);
const { shards, policyText } = await retriever.retrieve({
  taskDescription: 'Fix authentication bug in login flow',
});

// Enforce gates on tool calls
const gates = createGates(bundle);
const result = gates.evaluate({ tool: 'bash', args: { command: 'rm -rf /' } });
// result.blocked === true

// Audit with proof chain
const chain = createProofChain({ signingKey: process.env.PROOF_KEY! });
const envelope = chain.seal(runEvent);
chain.verify(envelope); // true โ€” tamper-evident

Key Modules

Import PathPurpose
@claude-flow/guidanceMain entry โ€” GuidanceControlPlane
@claude-flow/guidance/compilerCLAUDE.md โ†’ PolicyBundle compiler
@claude-flow/guidance/retrieverIntent classification + shard retrieval
@claude-flow/guidance/gates4 enforcement gates
@claude-flow/guidance/ledgerRun event logging + evaluators
@claude-flow/guidance/proofHMAC-SHA256 proof chain
@claude-flow/guidance/adversarialThreat, collusion, memory quorum
@claude-flow/guidance/trustTrust accumulation + privilege tiers
@claude-flow/guidance/authorityHuman authority + irreversibility classification
@claude-flow/guidance/wasm-kernelWASM-accelerated security-critical paths
@claude-flow/guidance/analyzerCLAUDE.md quality analysis + A/B benchmarking
@claude-flow/guidance/conformance-kitHeadless conformance test runner

Stats

  • 1,331 tests across 26 test files
  • 27 subpath exports for tree-shaking
  • WASM kernel for security-critical hot paths (gates, proof, scoring)
  • 25 ADRs documenting every architectural decision

Documentation