🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

code-warden

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-warden

Verifiable governance for AI-assisted development — checks, hooks, and evidence.

latest
Source
npmnpm
Version
3.4.0
Version published
Weekly downloads
355
Maintainers
1
Weekly downloads
 
Created
Source

code-warden

Portable AI Coding Governance Layer

Code-Warden provides verifiable governance for AI-assisted development. It does not just ask agents to follow rules. It makes them declare scope, patch order, blast radius, and verification before code is accepted. Local checks, CI enforcement, runtime hooks, and report artifacts keep that contract auditable after the chat scrolls away.

Four Layers

Code-Warden Four Layers

LayerWhat it does
Skill governanceScope Gate, Plan Gate, blast-radius checks, patch-first editing, research gates, drift signals, verification evidence
Local verificationwarden-lint, verify-secrets, get-context — directory-aware, no external deps
Installer and healthCross-app auto-installer, manifest-backed installs, --doctor, --verify-target, Windsurf adapter
Hard enforcementClaude Code PreToolUse hooks — block oversized writes and hardcoded secrets before the file system is touched

Governance Evidence

Generate a machine-readable governance report that can be stored in CI, attached to PRs, or used as audit evidence:

node tools/governance-report.js .                   # write .code-warden-report.json + summary
node tools/governance-report.js . --format=json      # JSON to stdout
node tools/governance-report.js . --format=md        # Markdown to stdout
node tools/governance-report.js . --format=sarif     # SARIF to stdout
node tools/governance-report.js . --format=sarif --out=code-warden.sarif

The report runs all checks in a single pass (file length, secrets, behavioral tests, source integrity) and produces a structured artifact:

{
  "tool": "code-warden",
  "version": "3.4.0",
  "checks": {
    "fileLength":      { "status": "pass", "filesScanned": 44, "violations": 0 },
    "secrets":         { "status": "pass", "filesScanned": 44, "violations": 0 },
    "behavioralTests": { "status": "pass", "tests": 21, "failures": 0 },
    "installHealth":   { "status": "pass" },
    "riskPolicy":      { "status": "pass" }
  },
  "result": "pass"
}

In CI, the Markdown format pipes directly into $GITHUB_STEP_SUMMARY for PR-visible evidence:

CheckResultDetails
File lengthPASS44 files scanned, 0 violations
Hardcoded credentialsPASS44 files scanned, 0 violations
Behavioral testsPASS24 tests, 0 failures
Install healthPASSAll source files present
Risk policyPASS7 governed actions

See templates/ci/github-actions.yml for the full CI template with artifact upload.

SARIF output is intentionally limited to source-located findings: CW001/max-file-length and CW002/hardcoded-credential. The JSON report remains the canonical governance artifact for behavioral tests, install health, runtime hook registration, and session gate evidence.

Governance Receipts

Reports prove repository checks ran. Receipts record the human-confirmed session contract that happened before edits:

code-warden receipt --template --out=code-warden-receipt.json
code-warden receipt --validate=code-warden-receipt.json

Receipt templates start as draft and canProveCompliance: false. Validation only passes after Scope Gate, Plan Gate, and final command evidence fields are filled. Code-Warden will not claim chat compliance that was not recorded.

GitHub Action

Use the repository action when you want the shortest CI setup:

- name: Code-Warden Governance Gate
  uses: Kodaxadev/Code-Warden@v3
  with:
    path: .

The action runs tools/governance-report.js, writes .code-warden-report.json, appends a Markdown summary, and uploads the report artifact by default.

Enable GitHub Code Scanning annotations by adding sarif: 'true' and granting the workflow security-events: write permission:

permissions:
  contents: read
  security-events: write

steps:
  - uses: actions/checkout@v6
  - name: Code-Warden Governance Gate
    uses: Kodaxadev/Code-Warden@v3
    with:
      path: .
      sarif: 'true'

Install

npx code-warden init

Or install globally:

npm install -g code-warden
code-warden init

CLI commands

CommandPurpose
code-warden initInstall to all detected AI runtimes
code-warden reportGenerate governance report
code-warden report --format=mdMarkdown output for PR summaries
code-warden report --format=sarifSARIF output for Code Scanning
code-warden report --format=sarif --out=code-warden.sarifWrite SARIF to a file
code-warden receipt --template --out=code-warden-receipt.jsonWrite a draft Scope Gate / Plan Gate receipt
code-warden receipt --validate=code-warden-receipt.jsonValidate completed receipt evidence
code-warden references <paths...>Recommend focused governance references for touched paths
code-warden doctorVerify source integrity + install health
code-warden listShow detected runtimes
code-warden hooks claudeInstall Claude Code PreToolUse hooks
code-warden hooks codexInstall Codex PreToolUse hooks (partial)
code-warden uninstall-hooks claudeRemove Claude Code hooks
code-warden uninstall-hooks codexRemove Codex hooks

Direct installer commands

CommandPurpose
node install.jsScan, prompt, install to detected apps
node install.js --allInstall without prompt
node install.js --dry-runPreview installs, write nothing
node install.js --listShow detected apps and detection method
node install.js --doctorVerify source integrity + per-target install health
node install.js --target=claude,cursorForce specific targets (warns if not detected)
node install.js --verify-target=claudeStrict health check — exits nonzero if not installed
node install.js --hooks=claudeInstall PreToolUse hooks into ~/.claude/settings.json
node install.js --uninstall-hooks=claudeRemove code-warden hook entries from settings

Supported targets: Claude Code, Cursor, Warp, OpenAI Codex, Windsurf, Generic Agents.

Each install writes a .code-warden-install.json manifest (version, target, format, timestamp).

npm scripts

npm run lint            # warden-lint on full project tree
npm run check-secrets   # verify-secrets on full project tree
npm run report          # governance report, writes .code-warden-report.json
npm run report:json     # governance report as JSON to stdout
npm run report:md       # governance report as Markdown to stdout
npm run install-auto    # node install.js
npm run install-dry-run # node install.js --dry-run
npm run install-list    # node install.js --list
npm run install-doctor  # node install.js --doctor
npm run smoke:npx       # verify published package from a clean temp directory
npm run test            # behavioral tests (24 scanner/report/receipt/risk/reference/hook cases)
npm run ci              # lint + secrets + test + doctor

Usage

Load at the start of any coding session. Trigger phrases:

  • "load code-warden" / "load protocol"
  • "begin coding" / "new session" / "governance check"
  • "start a new module" / "review this before we write"

The session sequence is enforced before any implementation:

Code-Warden Session Start Sequence

  • Architecture State (Re-injection Rule)
  • Session Scope (Session Scoping Rule)
  • Reference Files (Blueprint Rule)
  • Scope Gate — goal, non-goals, files in/out, verify commands, rollback
  • Plan Gate — patch order, blast radius class, post-patch checks

See examples/governed-session.md for an annotated example.

Optional Runtime Hooks

Code-Warden Hook Enforcement Flow

Install hard enforcement that runs at the PreToolUse level where the runtime exposes usable surfaces.

node install.js --hooks=claude  # full Write/Edit coverage
node install.js --hooks=codex   # partial apply_patch/Bash coverage

Claude Code

HookTriggerPolicy
warden-lint-hook.jsWrite or EditBlocks if resulting file exceeds line limit
warden-secrets-hook.jsWrite or EditHardcoded credential scanner — blocks if content matches any secret pattern

OpenAI Codex

HookTriggerPolicy
warden-apply-patch-hook.jsapply_patchBlocks added credentials and estimates resulting file size where a path is extractable
warden-bash-hook.jsBashBlocks command strings that contain hardcoded credentials

Codex cannot hook Write/Edit directly. CI enforcement closes the remaining gap. All hooks use exec form (node /path/to/hook.js) — no shell differences across platforms.

Thresholds are read from codewarden.json in the installed skill directory.

node install.js --uninstall-hooks=claude
node install.js --uninstall-hooks=codex

Doctor and --verify-target=<id> validate hook script paths when hooks are registered.

Configuration

All thresholds in codewarden.json:

SettingDefaultWhat it controls
thresholds.max_file_length400Lines before warden-lint.js flags a file
thresholds.pre_flight_trigger_lines150Lines before a pre-flight manifest is required
thresholds.human_checkpoint_files2Files touched before [AWAITING CONFIRMATION] is required
safety.exempt_from_blast_radiustests/, docs/, scripts/Paths excluded from rollback-plan rule
reference_selection.rules4 path rulesMaps touched paths to focused reference files
external_evidence.providers4 providersDescribes approved external evidence sources and trust limits
risk_policy.actions7 governed actionsMaps action classes to low, medium, high, or blocked

See CONFIGURE.md for team-size profiles and tuning rationale.

Default risk policy treats read-only context gathering as low, file edits as medium, dependency/network/release operations as high, and destructive or secret-bearing actions as blocked until explicitly scoped.

Reference selection is advisory. It helps agents load the right governance references for touched paths without pretending irrelevant rules disappeared.

External evidence providers are descriptive in this release line. SARIF, attestations, provenance, and scanner output should be recorded with scope and trust limits before being treated as governance evidence.

Reference Files

FileDomain
references/planning-gates.mdScope Gate and Plan Gate contracts
references/architecture.mdBlueprint Rule, Re-injection, State Update
references/safety.mdBlast Radius, Patch-First, Zero-Trust, Dependency Freeze
references/cognition.mdThink Before Coding, Don't Guess Syntax, Human Checkpoint
references/cleanup.mdTech Debt format, Test Contract, Decision Log
references/anti-drift.mdAnchor Check, Session Scoping, Drift Trigger Protocol
references/operations.mdVerification, source-control hygiene, dependency control
references/evidence-providers.mdExternal scanners, provenance, attestations, CI evidence, trust limits
references/research-and-fit.mdLive research gate, stack fit, product-shape guardrails
references/mcp-governance.mdMCP server approval, toolset scope, credentials, consent, audit evidence

Note for contributors

If testing npx code-warden from inside the Code-Warden source checkout, npm may prefer the local package context. Test from a separate directory for the same behavior users will see.

Run the external smoke test to exercise the published package from a clean temp directory:

npm run smoke:npx

The smoke test runs npx code-warden@latest --version, then npx code-warden@latest report --format=json, and verifies the report parses as a passing Code-Warden result.

Release Process

Code-Warden releases are tag-driven from GitHub Actions:

  • The workflow checks that package.json matches the pushed vX.Y.Z tag.
  • npm run ci verifies lint, secrets, behavioral tests, and install health.
  • npm publish --dry-run --access public verifies the package contents.
  • npm trusted publishing publishes the package without a long-lived npm token.
  • The workflow creates a GitHub release and uploads code-warden-vX.Y.Z.zip.

Configure npm trusted publishing for the repository before relying on the release workflow. Manual publishing remains a fallback, but it should be the exception because it does not provide the same CI-linked provenance story.

Author

Justin Davis — MIT License

Keywords

ai

FAQs

Package last updated on 19 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts