{"_id":"@4meta5/chain","_rev":"7-ac5b0489dcaba6bb5ab2da64d481db86","name":"@4meta5/chain","dist-tags":{"latest":"0.5.3"},"versions":{"0.1.0":{"name":"@4meta5/chain","version":"0.1.0","keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"author":{"name":"Amar Singh"},"license":"MIT","_id":"@4meta5/chain@0.1.0","maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"homepage":"https://github.com/4meta5/skills#readme","bugs":{"url":"https://github.com/4meta5/skills/issues"},"bin":{"chain":"bin/chain.js"},"dist":{"shasum":"8f3f2b4655affc3dd2f13abe695a2be6f5ff0876","tarball":"https://registry.npmjs.org/@4meta5/chain/-/chain-0.1.0.tgz","fileCount":234,"integrity":"sha512-9q4e53xTQXqU/ZTMaNEJnSdrI7cPBhNZwApYHKtTieej9MZhZRNV0p66WX6c5yecpJ6+7/iD4wiSLpcPJxNxTg==","signatures":[{"sig":"MEUCIEAf4XMzO/jhiEQnp95gLYk/R9j4WiY3apMR421pOn/vAiEA8qjzkwvEg0w2/+0fSscdZ6X6ESXRiOOBkjNtxO4X6H4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":712219},"main":"dist/src/index.js","type":"module","types":"dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"6cbe0f88d5a5d7c15ddfd34591fb179159d0def2","scripts":{"test":"vitest run","build":"tsc","test:all":"vitest run && vitest run --config vitest.property.config.ts","typecheck":"tsc --noEmit","test:watch":"vitest","test:property":"vitest run --config vitest.property.config.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"4meta5","email":"orlandodowntownhome@gmail.com"},"repository":{"url":"git+https://github.com/4meta5/skills.git","type":"git","directory":"packages/chain"},"_npmVersion":"11.6.2","description":"Declarative skill chaining for Claude Code workflows","directories":{},"_nodeVersion":"25.2.1","dependencies":{"cac":"^6.7.14","zod":"^4.3.6","glob":"^11.0.0","yaml":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.0.0","fast-check":"^4.5.3","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chain_0.1.0_1770012941192_0.010917977239114585","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@4meta5/chain","version":"0.2.0","keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"author":{"name":"Amar Singh"},"license":"MIT","_id":"@4meta5/chain@0.2.0","maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"homepage":"https://github.com/4meta5/skills#readme","bugs":{"url":"https://github.com/4meta5/skills/issues"},"bin":{"chain":"bin/chain.js"},"dist":{"shasum":"4ca3cbe9e635f640f2df710287a8d57429e96721","tarball":"https://registry.npmjs.org/@4meta5/chain/-/chain-0.2.0.tgz","fileCount":234,"integrity":"sha512-l9vkcBxzoufEqdxEHzXl3yI7onB1s+4G0PN2XbKql/t5iYNoq8vyubUSjtZIJoAUBia69kk+MYN96d9m0UcWlw==","signatures":[{"sig":"MEUCIQCX7fTRc58R+fgUv2s1bN7IJPiiS+TvT72mh2hXTAZ3HAIgGLbVJ0JCjgeevoeA5wmKTCJkjUqWFFzX5jTbdPbLgKs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":712219},"main":"dist/src/index.js","type":"module","types":"dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"2e5b4abe0f62c987427f566801f373f52d275af5","scripts":{"test":"vitest run","build":"tsc","test:all":"vitest run && vitest run --config vitest.property.config.ts","typecheck":"tsc --noEmit","test:watch":"vitest","test:property":"vitest run --config vitest.property.config.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"4meta5","email":"orlandodowntownhome@gmail.com"},"repository":{"url":"git+https://github.com/4meta5/skills.git","type":"git","directory":"packages/chain"},"_npmVersion":"11.6.2","description":"Declarative skill chaining for Claude Code workflows","directories":{},"_nodeVersion":"25.2.1","dependencies":{"cac":"^6.7.14","zod":"^4.3.6","glob":"^11.0.0","yaml":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.0.0","fast-check":"^4.5.3","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chain_0.2.0_1770170445514_0.4224363517703751","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@4meta5/chain","version":"0.3.0","keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"author":{"name":"Amar Singh"},"license":"MIT","_id":"@4meta5/chain@0.3.0","maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"homepage":"https://github.com/4meta5/skills#readme","bugs":{"url":"https://github.com/4meta5/skills/issues"},"bin":{"chain":"bin/chain.js"},"dist":{"shasum":"33eadc95517cb404a2e92e047f83b1b3ec27eb72","tarball":"https://registry.npmjs.org/@4meta5/chain/-/chain-0.3.0.tgz","fileCount":234,"integrity":"sha512-O83EN4PQQR6+/9zNSXfE+j1bnj6DyLN4XS1xVnJfRHJgp5B7S7AtlG1JZfHmQeHnetRJapiiBx2hKsLmnor0Tg==","signatures":[{"sig":"MEUCIAZWPp46A604OvlKQEiO4qn5jzyf3Jw4u3UrrMFmphWhAiEArY4pgyi7xrm+P011DY8gTJ76w1dkm6ydYwGxObbCKYs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":713575},"main":"dist/src/index.js","type":"module","types":"dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"6111ffcadc2d568e6fd96c9ec68511afc58e839c","scripts":{"test":"vitest run","build":"tsc","test:all":"vitest run && vitest run --config vitest.property.config.ts","typecheck":"tsc --noEmit","test:watch":"vitest","test:property":"vitest run --config vitest.property.config.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"4meta5","email":"orlandodowntownhome@gmail.com"},"repository":{"url":"git+https://github.com/4meta5/skills.git","type":"git","directory":"packages/chain"},"_npmVersion":"11.6.2","description":"Declarative skill chaining for Claude Code workflows","directories":{},"_nodeVersion":"25.2.1","dependencies":{"cac":"^6.7.14","zod":"^4.3.6","glob":"^11.0.0","yaml":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.0.0","fast-check":"^4.5.3","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chain_0.3.0_1770296777484_0.3266091046115085","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@4meta5/chain","version":"0.4.0","keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"author":{"name":"Amar Singh"},"license":"MIT","_id":"@4meta5/chain@0.4.0","maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"homepage":"https://github.com/4meta5/skills#readme","bugs":{"url":"https://github.com/4meta5/skills/issues"},"bin":{"chain":"bin/chain.js"},"dist":{"shasum":"d0dac6c57759059a2bd35dff5a8d9021337e90f1","tarball":"https://registry.npmjs.org/@4meta5/chain/-/chain-0.4.0.tgz","fileCount":234,"integrity":"sha512-bQu9xZD2vqTd+V8o1Uc8Yag3sMBhNRZ1JRp3oawaQs9ugER2l9kxs7MpKGsVNrdO2EIivFamhigcLmY+nMewaw==","signatures":[{"sig":"MEUCICBzP7bY0sADqSySrI73kt7df7Lrvwz1h1mAmXJSh86pAiEA848tBF3vdh+tsITv+pAkADaRZfd4c9sz26WkVin+NkI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":713599},"main":"dist/src/index.js","type":"module","types":"dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"76a6d2041fdc7810e63a0441d26574e4804ba0bb","scripts":{"test":"vitest run","build":"tsc","test:all":"vitest run && vitest run --config vitest.property.config.ts","typecheck":"tsc --noEmit","test:watch":"vitest","test:property":"vitest run --config vitest.property.config.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"4meta5","email":"orlandodowntownhome@gmail.com"},"repository":{"url":"git+https://github.com/4meta5/skills.git","type":"git","directory":"packages/chain"},"_npmVersion":"11.6.2","description":"Declarative skill chaining for Claude Code workflows","directories":{},"_nodeVersion":"25.2.1","dependencies":{"cac":"^6.7.14","zod":"^4.3.6","glob":"^11.0.0","yaml":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.0.0","fast-check":"^4.5.3","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chain_0.4.0_1771026915612_0.07688429452783496","host":"s3://npm-registry-packages-npm-production"}},"0.5.1":{"name":"@4meta5/chain","version":"0.5.1","keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"author":{"name":"Amar Singh"},"license":"MIT","_id":"@4meta5/chain@0.5.1","maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"homepage":"https://github.com/4meta5/skills#readme","bugs":{"url":"https://github.com/4meta5/skills/issues"},"bin":{"chain":"bin/chain.js"},"dist":{"shasum":"33fd9242626294d6e389fdbcbba8a44af539f44e","tarball":"https://registry.npmjs.org/@4meta5/chain/-/chain-0.5.1.tgz","fileCount":234,"integrity":"sha512-gOCbrcdo/Pe1+ounuqCjAnh039efuZjph/isclERBYRB9P1F9uHnP+2NsDjHeNkPynd3iZiqhSWcs8S8iw+QOA==","signatures":[{"sig":"MEUCIQDyGjjxqXy/maBYmwQot23zs+CZLuaxdssxj7AUV2GKmgIgGiEILV98A+eYP5EWxeOzOT+mHLtQVIuwALNFp74o3dc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":713599},"main":"dist/src/index.js","type":"module","types":"dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"52c629415cc261d1d0c4b68d86a0ad8ec06883df","scripts":{"test":"vitest run","build":"tsc","test:all":"vitest run && vitest run --config vitest.property.config.ts","typecheck":"tsc --noEmit","test:watch":"vitest","test:property":"vitest run --config vitest.property.config.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"4meta5","email":"orlandodowntownhome@gmail.com"},"repository":{"url":"git+https://github.com/4meta5/skills.git","type":"git","directory":"packages/chain"},"_npmVersion":"11.6.2","description":"Declarative skill chaining for Claude Code workflows","directories":{},"_nodeVersion":"25.2.1","dependencies":{"cac":"^6.7.14","zod":"^4.3.6","glob":"^11.0.0","yaml":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.0.0","fast-check":"^4.5.3","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chain_0.5.1_1771100527428_0.051152747722644554","host":"s3://npm-registry-packages-npm-production"}},"0.5.2":{"name":"@4meta5/chain","version":"0.5.2","keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"author":{"name":"Amar Singh"},"license":"MIT","_id":"@4meta5/chain@0.5.2","maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"homepage":"https://github.com/4meta5/skills#readme","bugs":{"url":"https://github.com/4meta5/skills/issues"},"bin":{"chain":"bin/chain.js"},"dist":{"shasum":"c114f29bb2cf83b6efd0a7343fd84cae365710de","tarball":"https://registry.npmjs.org/@4meta5/chain/-/chain-0.5.2.tgz","fileCount":234,"integrity":"sha512-3hAvAQD5Wiqs/eAwrFBT6ZqgEelmlcxDszki2FrxQuiLZSZRVY2RXjKK5RSapk4oAwrOzzpyjgk7xotVcJfplg==","signatures":[{"sig":"MEUCIGldYYMF8xAPvTVkBLxIyy8RjR/tFz0r9eyqcSCHoF1SAiEAzsd6mYLuz+CE/bgLDZ/+PIC/6Z9qOTCB1mSOkMXlPOU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":713599},"main":"dist/src/index.js","type":"module","types":"dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"cd5dd7db868244a0ba173e506bac18617ebc8908","scripts":{"test":"vitest run","build":"tsc","test:all":"vitest run && vitest run --config vitest.property.config.ts","typecheck":"tsc --noEmit","test:watch":"vitest","test:property":"vitest run --config vitest.property.config.ts","prepublishOnly":"npm run build"},"_npmUser":{"name":"4meta5","email":"orlandodowntownhome@gmail.com"},"repository":{"url":"git+https://github.com/4meta5/skills.git","type":"git","directory":"packages/chain"},"_npmVersion":"11.6.2","description":"Declarative skill chaining for Claude Code workflows","directories":{},"_nodeVersion":"25.2.1","dependencies":{"cac":"^6.7.14","zod":"^4.3.6","glob":"^11.0.0","yaml":"^2.3.0"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.0.0","fast-check":"^4.5.3","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chain_0.5.2_1771104595054_0.5268120950182549","host":"s3://npm-registry-packages-npm-production"}},"0.5.3":{"name":"@4meta5/chain","version":"0.5.3","description":"Declarative skill chaining for Claude Code workflows","type":"module","main":"dist/src/index.js","types":"dist/src/index.d.ts","bin":{"chain":"bin/chain.js"},"exports":{".":{"import":"./dist/src/index.js","types":"./dist/src/index.d.ts"}},"scripts":{"build":"tsc","test":"vitest run","test:watch":"vitest","test:property":"vitest run --config vitest.property.config.ts","test:all":"vitest run && vitest run --config vitest.property.config.ts","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"author":{"name":"Amar Singh"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/4meta5/skills.git","directory":"packages/chain"},"homepage":"https://github.com/4meta5/skills#readme","bugs":{"url":"https://github.com/4meta5/skills/issues"},"dependencies":{"cac":"^6.7.14","glob":"^11.0.0","yaml":"^2.3.0","zod":"^4.3.6"},"devDependencies":{"@types/node":"^20.0.0","fast-check":"^4.5.3","typescript":"^5.0.0","vitest":"^1.0.0"},"gitHead":"1fc8d9fd71f7225845659c0557cd818e59c8200d","_id":"@4meta5/chain@0.5.3","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-hh08WPiTEW4ibeIEK7x9EyJvbuBFr+zEXAJxymA0O7grSwpo6ma3lJSiySslISeLfISpr7xpYq2Ui3zm/EE/KQ==","shasum":"db3de542edd7fe47e9236ea1f7ce02d618ca7c07","tarball":"https://registry.npmjs.org/@4meta5/chain/-/chain-0.5.3.tgz","fileCount":234,"unpackedSize":713599,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD3Tyy6CGzMJS0KeR+Hd1g9zXhe1oi+GkAETqB05ZvWzAIhANIeLVNj+CCdnbSRnNIFiTsBIXf8CdtT1Y0IBo69S7Pq"}]},"_npmUser":{"name":"4meta5","email":"orlandodowntownhome@gmail.com"},"directories":{},"maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chain_0.5.3_1771107331176_0.33361021527938695"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-02T06:15:41.068Z","modified":"2026-02-14T22:15:31.419Z","0.1.0":"2026-02-02T06:15:41.332Z","0.2.0":"2026-02-04T02:00:45.727Z","0.3.0":"2026-02-05T13:06:17.624Z","0.4.0":"2026-02-13T23:55:15.774Z","0.5.1":"2026-02-14T20:22:07.576Z","0.5.2":"2026-02-14T21:29:55.208Z","0.5.3":"2026-02-14T22:15:31.314Z"},"bugs":{"url":"https://github.com/4meta5/skills/issues"},"author":{"name":"Amar Singh"},"license":"MIT","homepage":"https://github.com/4meta5/skills#readme","keywords":["claude","ai","skills","workflow","chain","dag","orchestration"],"repository":{"type":"git","url":"git+https://github.com/4meta5/skills.git","directory":"packages/chain"},"description":"Declarative skill chaining for Claude Code workflows","maintainers":[{"name":"4meta5","email":"orlandodowntownhome@gmail.com"}],"readme":"# @4meta5/chain\n\nDeclarative skill chaining for Claude Code workflows.\n\n## Overview\n\nChain enforces development workflows through capability-based skill resolution. Define what capabilities are required for a task (like `test_written`, `test_green`), and Chain automatically:\n\n1. **Matches prompts to profiles** - Detects task type from your prompt\n2. **Resolves skill chains** - Finds skills that provide required capabilities\n3. **Enforces tool gates** - Blocks tools until capabilities are satisfied\n4. **Tracks progress** - Persists session state across invocations\n\n## Quick Start\n\n```bash\n# Install\nnpm install @4meta5/chain\n\n# Validate your configuration\nchain validate\n\n# Manually activate a profile\nchain activate bug-fix\n\n# Check current session status\nchain status\n\n# Use in Claude Code hooks (auto-activates based on prompt)\nchain hook-pre-tool-use --tool '{\"tool\":\"Write\"}' --prompt \"fix the login bug\"\n```\n\n## Configuration\n\nChain uses two YAML files in a `chains/` directory:\n\n### chains/skills.yaml\n\nDefines available skills and what they provide:\n\n```yaml\nversion: \"1.0\"\n\nskills:\n  - name: tdd\n    skill_path: .claude/skills/tdd\n    provides: [test_written, test_green, test_refactored]\n    requires: []\n    conflicts: []\n    risk: low\n    cost: low\n    artifacts: [\"**/*.test.ts\"]\n    tool_policy:\n      deny_until:\n        write_impl:\n          until: test_written\n          reason: \"RED phase: Write failing test first\"\n        commit:\n          until: test_green\n          reason: \"GREEN phase: Tests must pass\"\n```\n\n### chains/profiles.yaml\n\nDefines workflow profiles and their requirements:\n\n```yaml\nversion: \"1.0\"\n\ndefault_profile: permissive\n\nprofiles:\n  - name: bug-fix\n    description: TDD workflow for bug fixes\n    match: [fix, bug, broken, error, failing test]\n    capabilities_required: [test_written, test_green, test_refactored]\n    strictness: strict\n    priority: 10\n    completion_requirements:\n      - name: tests_pass\n        type: command_success\n        command: npm test\n\n  - name: permissive\n    description: No enforcement\n    match: []\n    capabilities_required: []\n    strictness: permissive\n    priority: 0\n```\n\n## How It Works\n\n### Profile Matching\n\nWhen you use `--prompt`, Chain matches your prompt to profiles using regex patterns:\n\n```bash\n# \"fix the login bug\" matches bug-fix profile (contains \"fix\" and \"bug\")\nchain hook-pre-tool-use --tool '{\"tool\":\"Write\"}' --prompt \"fix the login bug\"\n```\n\nHigher scores (more pattern matches) win. On ties, higher priority wins.\n\n### Capability Resolution\n\nChain builds a DAG of skills based on capabilities:\n\n```\nRequired: test_written, test_green\n    ↓\nResolution:\n  1. tdd provides [test_written, test_green] → selected\n    ↓\nChain: [tdd]\n```\n\nSkills can have requirements (`requires: [X]`), which Chain resolves recursively.\n\n### Tool Gating\n\nSkills define what tools are blocked until capabilities are satisfied:\n\n```yaml\ntool_policy:\n  deny_until:\n    write:\n      until: test_written\n      reason: \"Write failing test first (TDD RED)\"\n```\n\nWhen the hook runs, it checks if the tool's intent is blocked:\n\n```bash\n$ chain hook-pre-tool-use --tool '{\"tool\":\"Write\"}'\nCHAIN ENFORCEMENT: BLOCKED\n\nIntent: write\nReason: Write failing test first (TDD RED)\n```\n\n### Path-Aware Intents\n\nChain supports fine-grained blocking based on file paths. Instead of blocking all writes, you can target specific file categories:\n\n| Intent | Description | Example Files |\n|--------|-------------|---------------|\n| `write_test` | Writing test files | `*.test.ts`, `*.spec.js`, `tests/` |\n| `write_impl` | Writing implementation files | `src/*.ts`, `lib/*.js` |\n| `write_docs` | Writing documentation | `*.md`, `docs/`, `README` |\n| `write_config` | Writing configuration | `*.json`, `*.yaml`, `.env` |\n\n**TDD Example:** Block implementation writes until tests exist, but always allow writing tests:\n\n```yaml\ntool_policy:\n  deny_until:\n    write_impl:\n      until: test_written\n      reason: \"TDD RED: Write a failing test first\"\n    commit:\n      until: test_green\n      reason: \"TDD GREEN: Tests must pass\"\n```\n\nWith this config:\n- `Write` to `src/index.ts` → **blocked** (write_impl)\n- `Write` to `src/index.test.ts` → **allowed** (write_test)\n- `Write` to `README.md` → **allowed** (write_docs)\n\n**Fallback behavior:** If you block the base `write` intent, it blocks all file writes regardless of category. Path-aware intents provide finer control when needed.\n\n### Session Persistence\n\nChain stores session state in `.chain-state.json`:\n\n```json\n{\n  \"session_id\": \"auto-1234567890\",\n  \"profile_id\": \"bug-fix\",\n  \"chain\": [\"tdd\"],\n  \"capabilities_required\": [\"test_written\", \"test_green\"],\n  \"capabilities_satisfied\": [],\n  \"blocked_intents\": {\n    \"write\": \"Write failing test first (TDD RED)\"\n  }\n}\n```\n\n## CLI Commands\n\n| Command | Description |\n|---------|-------------|\n| `chain validate` | Validate skills.yaml and profiles.yaml |\n| `chain resolve <profile>` | Show skill chain for a profile |\n| `chain explain <profile>` | Explain why each skill was selected |\n| `chain mermaid <profile>` | Generate Mermaid diagram |\n| `chain activate <profile>` | Start a workflow session |\n| `chain activate-route` | Activate from RouteDecision (router integration) |\n| `chain status` | Show current session status |\n| `chain next` | Show next skill and guidance |\n| `chain clear` | Clear current session |\n| `chain hook-pre-tool-use` | PreToolUse hook for Claude Code |\n| `chain hook-stop` | Stop hook for Claude Code |\n\n### Hook Options\n\n```bash\nchain hook-pre-tool-use \\\n  --tool '{\"tool\":\"Write\",\"input\":{\"path\":\"src/foo.ts\"}}' \\\n  --prompt \"fix the login bug\" \\  # Optional: enables auto-activation\n  --no-auto                       # Optional: disable auto-activation\n  --cwd /path/to/project          # Optional: working directory\n```\n\n## Programmatic API\n\n```typescript\nimport {\n  ChainActivator,\n  createRouteDecision,\n  PreToolUseHook,\n  matchProfileToPrompt,\n  resolve,\n  loadConfig,\n} from '@4meta5/chain';\n\n// Load configuration\nconst config = await loadConfig('/path/to/project');\n\n// === Router Integration ===\n// Activate from a RouteDecision (for middleware integration)\nconst activator = new ChainActivator(cwd, config.skills, config.profiles);\n\nconst decision = createRouteDecision(\n  'req-123',                    // request_id for idempotency\n  'fix the login bug',          // query\n  'immediate',                  // mode: immediate | suggestion | chat\n  [{ name: 'bug-fix', score: 0.9 }]  // candidates\n);\n\nconst activation = await activator.activate(decision);\n// → { activated: true, session_id: '...', chain: ['tdd'], blocked_intents: {...} }\n\n// Idempotent: same request_id returns existing session\nconst same = await activator.activate(decision);\n// → { activated: true, idempotent: true, session_id: same as before }\n\n// === Profile Matching ===\n// Match prompt to profile\nconst profile = matchProfileToPrompt(\n  'fix the login bug',\n  config.profiles\n);\n// → { name: 'bug-fix', matchScore: 2, matchedPatterns: ['fix', 'bug'], ... }\n\n// Resolve skill chain\nconst result = resolve(profile, config.skills);\n// → { chain: ['tdd'], blocked_intents: { write_impl: '...' }, ... }\n\n// === Hook Usage ===\n// Use the hook\nconst hook = new PreToolUseHook(cwd, config.skills, config.profiles);\nconst result = await hook.check(\n  { tool: 'Write', input: { path: 'src/foo.ts' } },\n  { prompt: 'fix the login bug' }\n);\n// → { allowed: false, message: 'BLOCKED...', blockedIntents: [...] }\n```\n\n## Integration with Claude Code\n\nAdd to your `.claude/settings.json`:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \".*\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"chain hook-pre-tool-use --tool '$TOOL_INPUT'\"\n          }\n        ]\n      }\n    ],\n    \"Stop\": [\n      {\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"chain hook-stop\"\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n## Strictness Levels\n\n| Level | Behavior |\n|-------|----------|\n| `strict` | Block tools until requirements met |\n| `advisory` | Warn but allow tools |\n| `permissive` | No enforcement |\n\n## Related Skills\n\nChain works with skills from [4meta5/skills](https://github.com/4meta5/skills):\n\n- **tdd** - Test-Driven Development (RED → GREEN → REFACTOR)\n- **dogfood** - Enforce dogfooding the tools you build\n- **repo-hygiene** - Repository cleanup and documentation\n\n## License\n\nMIT\n","readmeFilename":"README.md"}