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

lawspec

v0.36.4

Published

State the law once. Check it everywhere.

Readme

LawSpec

State the law once. Check it everywhere.

Platform status — 2026-11-09: The opt-in component runtime ships precompiled native packages. Linux x64 is accepted on emulated execution and macOS x64 is unverified. See the release status.

Development status: The full Haskell application port is incomplete; the existing runtime remains the default. See the application work and acceptance gates.

LawSpec is a specification language for the laws your code must obey. It compiles reusable laws and concrete examples into native property-based tests and implementation adapters for Java, Python, JavaScript, TypeScript, Go, Haskell, Kotlin, Rust, C#, F#, Swift, Erlang, Elixir, Gleam, Clojure, Groovy and Scala. The compiler is written in Haskell and distributed on npm as prebuilt WebAssembly, with a Node CLI and a typed JavaScript API.

The examples below use the current canonical authoring profile. The npm package includes the compiler and learning track; no Haskell installation is needed.

Features

Install

Node 22+ and the selected target's build tools are required. No Haskell toolchain is needed. The reference platforms are macOS and Linux. Native Windows is supported for the CLI with the Java, Kotlin, Groovy, Scala, JavaScript and TypeScript targets; the other targets are best-effort there, and WSL runs all of them. See compatibility.

To open the learning track locally:

npm install --global [email protected]
lawspec learn

Open the printed loopback URL, or use Learn on GoForge. Six lessons pair worked examples with practice in F#, TypeScript or JavaScript. The course is a teaching preview; later lessons and capstones remain deferred.

A checkout holds sources only: Git keeps no build output, so build the package before using it. That needs Stack and the GHC WebAssembly toolchain (Contribute); the npm release above does not. To try a checkout's build in a new, empty directory, initialize before installing, so that LawSpec can create package.json and its test script:

git clone https://github.com/brain-fuel/lawspec.git lawspec
make -C lawspec wasm
(cd lawspec && tools/wasm-host-core.sh)
npm ci --ignore-scripts --prefix lawspec/npm
mkdir lawspec-example
cd lawspec-example
node ../lawspec/npm/bin/lawspec.mjs init --target javascript
npm install --save-dev ../lawspec/npm
npx lawspec --version
npx lawspec check
npx lawspec explain 'example.codec::codec'
npx lawspec doctor

npm ci installs the checkout's own dependencies: npm links a directory outside the project and does not install that directory's dependencies. Installing the link needs no flags, and --ignore-scripts also works. If your registry mirror does not have a released version yet, install from a release tarball. ricestax, which only lawspec project uses, is an optional package.

New projects start with verification.layers: []: intrinsic definition checks run, and no law verification is selected. Set verification.layers to [:property :examples] in lawspec.edn, then run npx lawspec generate. Implement src/example/codec.mjs, then run npm test:

export function itoa(value) { return String(value); }
export function atoi(value) { return Number(value); }

In an existing project, install the checkout's npm directory first, then run npx lawspec init --target javascript. init adds "type": "module" and the fast-check development dependency to your package.json, installs dependencies and runs the doctor checks. See Install LawSpec and create a project.

Codex and Claude Code plugin

The Git-backed brain-fuel marketplace includes the LawSpec plugin with three skills: lawspec-author for specifications and adapters, lawspec-project for project discovery and changes, and lawspec-learn for tutoring. The skills print their references (the authoring guide, compiler inventory, library reference and course) with lawspec reference, so they always match the installed compiler and need no repository checkout. Install the LawSpec CLI separately with Node 22+:

npm install --global [email protected]

For Codex, run these commands in your terminal:

codex plugin marketplace add brain-fuel/lawspec \
  --sparse .agents/plugins --sparse plugins/lawspec
codex plugin add lawspec@brain-fuel

For Claude Code, run:

claude plugin marketplace add brain-fuel/lawspec \
  --sparse .claude-plugin plugins/lawspec
claude plugin install lawspec@brain-fuel

Alternatively, inside Claude Code use /plugin marketplace add brain-fuel/lawspec and /plugin install lawspec@brain-fuel. Start a new session after installation. Ask Codex to use lawspec-author, or invoke /lawspec:lawspec-author in Claude Code; the project and tutor skills follow the same naming pattern.

The terminal commands use sparse checkouts for the marketplace and plugin directories. For a local checkout, omit --sparse and its paths and replace brain-fuel/lawspec with the checkout's absolute path. To pin a release in Codex, append --ref v0.36.4 to its marketplace-add command. In Claude Code, use https://github.com/brain-fuel/lawspec.git#v0.36.4 as the marketplace source. Private repository installations require your existing GitHub access.

To refresh the Git source, run codex plugin marketplace upgrade brain-fuel or claude plugin marketplace update brain-fuel; in Claude Code then run claude plugin update lawspec@brain-fuel. In Codex, reinstall with codex plugin add lawspec@brain-fuel to select the refreshed package. Restart the host to load updated skills.

This is a repository marketplace, not a listing in either host's curated public directory. The plugin has its own version, in its two host manifests (plugins/lawspec/.claude-plugin/plugin.json and .codex-plugin/plugin.json, kept identical); the course remains a teaching preview. The skills hold only their instructions: they print the authoring guide, compiler inventory, library reference, law source and course with lawspec reference, so they need the lawspec CLI installed and always match its version. See the official Codex marketplace documentation and Claude Code marketplace documentation.

MCP server

LawSpec can expose a project's compiler through a local MCP server. From the project directory, run npx lawspec mcp; a host can also launch that command as a child process. To inspect it interactively, run:

npx @modelcontextprotocol/inspector npx lawspec mcp

The server provides lawspec_check, lawspec_list_laws, and lawspec_explain. It reads the project's lawspec.edn, validates definitions, and reports the configured law verification and its evidence statuses. See the MCP server guide for host setup and details.

Example

unit example.atoi_codec

itoa :: Int32 -> Text
atoi :: Text -> Int32

law "|round trip| is
  definition :
    apply law "|left inverse| atoi itoa
  end definition
  description :
    "applying {itoa} and then {atoi} recovers the original integer"
  end description
  example "|negative integers use a minus sign and round-trip unchanged| :
    x = -42
    expect itoa x = "-42"
    expect atoi (itoa x) = -42
  end example
end law
end unit

lawspec explain says what the law checks, in plain English:

Law: round trip
applying {itoa} and then {atoi} recovers the original integer
For every x (an Int32):
  The atoi for the itoa for this x must be this x.

--view dev shows the expanded property atoi (itoa x) = x with its examples. --view math uses mathematical notation.

The generated tests check the example, signed 32-bit boundary cases and randomized inputs against your itoa and atoi, on whichever targets you configure.

Targets

| Target | Build setup | Test libraries | Test command | | --- | --- | --- | --- | | java | Maven, JDK 25, release 25 (or release 21) | JetCheck 0.3.0, JUnit Jupiter 5.14.x or 6.0.x | mvn test | | python | Python 3.13 or 3.14, pyproject | pytest 8.4.x, Hypothesis 6.135.26+ (6.x) | python -m pytest | | javascript | Node 22+, npm, ESM | fast-check 4.x, node:test | npm test | | typescript | Node 22+, npm, TypeScript 5.9.x, ESM | fast-check 4.x, node:test | npm test | | go | Go modules, Go 1.22–1.26 | Rapid 1.2.0, testing | go test ./... | | haskell | Stack, GHC 9.10, LTS 24.58 | Hspec 2.11, Hedgehog 1.5, hspec-hedgehog 0.3 | stack test | | kotlin | JDK/JVM 25, Gradle 9.1–9.3, Kotlin 2.3.21 | Kotest 5.9.1 | gradle test | | rust | Rust 1.85+, edition 2024, Cargo | Proptest 1.11.0 | cargo test |

See the target guides.

The Prolog target uses SWI-Prolog 10+, Janus and Python 3.13+, with PLUnit slots over pytest and Hypothesis. Its public interfaces are implemented; the full shared native acceptance matrix remains open.

The artifact targets generate HCL variables and values, YAML configuration and schemas, ANTLR data grammars, and Make pipelines. These targets emit no application law tests.

Documentation

The documentation has tutorials, how-to guides, a reference for the language, CLI, configuration and API, and explanations of the design. Release history is in the changelog. To work on LawSpec itself, see contributing.

Syntax highlighting is available as a VS Code extension.

License

MIT. See LICENSE.

Start or adopt a project without choosing a language with lawspec project init or lawspec project adopt. lawspec project status separates Canon decisions from LawSpec evidence; lawspec project validate checks definitions and the configured verification layers. Project workflow.