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

openapi-drift-guard

v0.1.0

Published

AI-powered OpenAPI drift guard — detect drift between OpenAPI spec and implementation. Semantic validation via Claude Code Skill

Readme

🔍 OpenAPI Drift Guard

AI-powered API contract drift detection — detect breaking changes between OpenAPI/Swagger specs and implementation code before they reach production.

npm version license

中文文档


🎯 The Problem It Solves

| Scenario | Traditional Testing | OpenAPI Drift Guard | |----------|--------------------|------------------------| | "Is this endpoint documented?" | ❌ Manual review | ✅ Auto-detect missing/phantom endpoints | | "Will this change break clients?" | ⚠️ Runtime tests only | ✅ Static analysis before deploy | | "Is the response schema correct?" | ❌ Integration tests | ✅ Schema comparison with severity levels |

Core insight: Breaking changes should be caught at design time, not after deployment.


✨ Core Features

🔍 OpenAPI/Swagger Parsing (v0.1.0)

  • OpenAPI 3.x — JSON/YAML parsing with full schema support
  • Swagger 2.0 — Automatic normalization to OpenAPI 3.0
  • $ref Resolution — Recursive reference resolution
  • Unified ModelNormalizedEndpoint for spec and code

🧠 Code Analysis (v0.2.0+)

  • Express/Fastify/Koa/NestJS/Hono route extraction
  • TypeScript type inference for request/response
  • Parameter extraction from route definitions

🔄 Drift Detection

8 drift types with severity classification:

| Drift Type | Severity | Example | |------------|----------|---------| | Missing Endpoint | 🔴 Breaking | Code has endpoint not in spec | | Phantom Endpoint | 🔴 Breaking | Spec has endpoint not in code | | Type Mismatch | 🔴 Breaking | Field type changed | | Missing Field | 🔴 Breaking | Required field removed | | Extra Field | 🟡 Warning | Optional field removed | | Required Mismatch | 🟡 Warning | Required/optional flip | | Response Code Mismatch | 🟢 Info | Status code changed | | Deprecated Not Removed | 🟢 Info | Deprecated still in use |


⚡ Quick Start (5 Minutes)

# Option 1: Zero-install CLI (fastest)
npx openapi-drift-guard validate --spec openapi.yaml --code src/

# Option 2: Install globally
npm install -g openapi-drift-guard
openapi-drift-guard validate --spec openapi.yaml --code src/

# Option 3: Use in Node.js project
npm install openapi-drift-guard

First run results:

  • ✅ Spec parsed: 12 endpoints detected
  • ✅ Code analyzed: 15 endpoints found
  • 📊 Drift detected: 3 breaking changes found

See Getting Started for detailed usage.


🚀 Getting Started

Option 1: Claude Code Plugin (Recommended)

# In Claude Code, run:
/plugin marketplace add saqqdy/openapi-drift-guard
/plugin install openapi-drift-guard

Available Commands

| Command | Description | Example | |---------|-------------|---------| | /validate | Validate contract drift | /validate openapi.yaml src/ | | /drift | Endpoint drift detail | /drift POST /users | | /contract | Operation contract check | /contract createUser | | /check-api | Area batch validation | /check-api user-management | | /api-drift | Auto-fix suggestions | /api-drift --fix |

Option 2: NPM Package

pnpm add openapi-drift-guard
import { parseAndNormalizeSpec, createAnalyzer, detectDrifts } from 'openapi-drift-guard'

// Parse spec
const specEndpoints = parseAndNormalizeSpec('./openapi.yaml')

// Analyze code
const analyzer = createAnalyzer('express', './src')
const codeEndpoints = analyzer.analyze()

// Detect drifts
const drifts = detectDrifts(specEndpoints, codeEndpoints)
console.log(`Found ${drifts.length} drifts`)

Option 3: CLI (Zero-Install)

# In any project
npx openapi-drift-guard validate --spec ./openapi.yaml --code ./src
npx openapi-drift-guard --version
npx openapi-drift-guard --help

Option 4: Clone and Run Examples

git clone https://github.com/saqqdy/openapi-drift-guard.git
cd openapi-drift-guard
pnpm install

# Run examples
npx tsx examples/basic-usage.ts
npx tsx examples/with-config.ts
npx tsx examples/skill-commands.ts

📋 Version Roadmap

| Version | Codename | Theme | Status | |---------|----------|-------|--------| | v0.1.0 | Daybreak | Spec parsing + Express analyzer | ✅ Current | | v0.2.0 | Sunrise | Multi-framework support | 📋 Planned | | v0.3.0 | Dawn | Claude Code Skill ready | 📋 Planned | | v0.4.0 | Ember | CI/CD integration + SARIF | 📋 Planned | | v1.0.0 | Lighthouse | Production-ready | 📋 Planned |


🗂️ Project Structure

openapi-drift-guard/
├── .claude/skills/openapi-drift-guard/  # Skill prompts (core product)
│   └── skill.md                            # Commands + execution flow
├── src/                                    # TypeScript source
│   ├── parser/                             # OpenAPI/Swagger parser
│   ├── analyzer/                           # Code analyzers
│   ├── detector/                           # Drift detection
│   ├── types/                              # Core types
│   └── utils/                              # Utilities
├── examples/                               # Usage examples
├── docs/                                   # VitePress docs
└── internal/                               # Planning docs

🛠️ Development

pnpm install          # Install dependencies
pnpm run lint         # ESLint + auto-fix
pnpm run typecheck    # TypeScript check
pnpm run test         # Run tests (vitest)
pnpm run build        # Build (ESM + CJS)
pnpm run docs:dev     # Start docs server

🆚 Comparison

vs Schema Validation

| Dimension | Schema Validation | OpenAPI Drift Guard | |-----------|-------------------|------------------------| | Timing | Runtime | Design time | | Coverage | Single request | Full API surface | | Drift Detection | ❌ No | ✅ 8 drift types | | Code Analysis | ❌ No | ✅ Framework-aware | | Severity Levels | ❌ No | ✅ 🔴🟡🟢 classification |


📄 License

MIT

👤 Author

saqqdy https://github.com/saqqdy

🙏 Acknowledgments

Inspired by git-unearth's project structure and documentation style.