npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ralph-gate

v0.3.3

Published

Structured verification gates for Claude Code - prevent premature completion with ordered validation checks

Downloads

527

Readme

Ralph Gate

Structured verification gates for Claude Code - Prevent premature completion with ordered validation checks.

Ralph Gate is a minimal TypeScript plugin that provides verification gates for Claude Code, preventing false completion by running ordered verification commands before allowing the agent to stop.

Features

  • Fail-Fast Execution: Stops at first blocking failure to save time
  • Ordered Gates: Run checks from cheapest to most expensive
  • Non-Blocking Gates: Support for warning-only checks that don't stop execution
  • Hook Integration: Seamlessly integrates with Claude Code's stop hook
  • Hook Progress Streaming: Stream gate output to stderr so hooks don't look stuck
  • Full Programmatic API: Use as a library in your own tools
  • Zero Runtime Dependencies: Lightweight and fast
  • ESM-Only: Modern Node.js (>=18)

Installation

npm install -D ralph-gate

Quick Start

  1. Initialize Ralph Gate in your project:
npx ralph-gate init

This command automatically:

  • Generates a gate.config.json based on your project scripts
  • Configures the Claude Code verification hook
  • Updates .gitignore
  1. Now when Claude Code tries to stop, your gates will run first!

Configuration

Gate Fields

| Field | Type | Default | Description | | ------------- | ------- | -------- | --------------------------------------- | | name | string | required | Unique identifier for the gate | | command | string | required | Shell command to execute | | description | string | - | Human-readable description | | order | number | 100 | Execution order (lower = earlier) | | enabled | boolean | true | Whether to run this gate | | blocking | boolean | true | If false, failures warn but don't block |

Config Fields

| Field | Type | Default | Description | | ------------ | ------- | ------------------------- | --------------------------------- | | gates | Gate[] | required | Array of gate definitions | | failFast | boolean | true | Stop after first blocking failure | | outputPath | string | "gate-results-.json" | Path for result file |

Example Configuration

{
  "gates": [
    {
      "name": "lint",
      "command": "npm run lint",
      "description": "Run ESLint",
      "order": 10
    },
    {
      "name": "typecheck",
      "command": "tsc --noEmit",
      "order": 20
    },
    {
      "name": "test",
      "command": "npm test",
      "order": 30
    },
    {
      "name": "audit",
      "command": "npm audit",
      "order": 50,
      "blocking": false
    }
  ],
  "failFast": true
}

CLI Reference

# Initialize project configuration
npx ralph-gate init

# Run all gates with console output
npx ralph-gate

# Run in hook mode (JSON output, always exits 0)
npx ralph-gate --hook

# Preview which gates would run
npx ralph-gate --dry-run

# Run a single gate
npx ralph-gate --only typecheck

# Verbose mode with real-time output
npx ralph-gate --verbose

Programmatic API

Ralph Gate can be used as a library in your own tools:

import { runGates, loadConfig, generateHookResponse } from 'ralph-gate';

// Load and run gates
const config = await loadConfig();
const summary = await runGates(config);

// Generate hook response
const hookResponse = generateHookResponse(summary);
console.log(hookResponse);

Available Exports

export { runGates } from './runner';
export { loadConfig } from './config';
export { generateHookResponse } from './hook';
export { formatConsoleOutput, formatFailureContext } from './output';
export type {
  Gate,
  GateResult,
  GateRunSummary,
  GateConfig,
  HookOutput,
} from './types';

How It Works

  1. Stop Event: Claude Code triggers the stop hook
  2. Gate Runner: Executes gates in order (cheap → expensive)
  3. Fail-Fast: Stops at first blocking failure
  4. Result File: Writes gate-results-<pid>.json
  5. Hook Response: Returns JSON to Claude Code
    • Pass: {} (allow completion)
    • Fail: {"decision": "block", "reason": "<context>", "warnings": [...]}

Non-Blocking Gates

Gates with blocking: false will collect failures as warnings but won't prevent completion:

{
  "gates": [
    {
      "name": "audit",
      "command": "npm audit",
      "blocking": false
    }
  ]
}

Design Principles

  • Exit 0 in hook mode: Control via JSON decision field
  • Fail-fast default: Skip expensive gates if cheap ones fail
  • Truncated failure context: Stdout + stderr with head/tail truncation (max 4000 chars)
  • Zero runtime dependencies: Only dev deps for build/test
  • ESM-only: Modern Node.js (>=18)
  • Trust exit codes: Exit 0 = pass regardless of stderr

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © Uzair Akram