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

@erseco/code-snippets-client

v0.1.6

Published

TypeScript client and CLI for the WordPress Code Snippets REST API, with WordPress and CAS authentication

Readme

Code Snippets Client

CI codecov npm Publish License: GPL v3 or later

A TypeScript client and CLI for the WordPress Code Snippets REST API. List, create, update, activate, deactivate and delete snippets from Node.js, using application passwords, WordPress login, existing sessions or CAS forms. An independent, unofficial project. Not the WPCode plugin.

Coverage treemap

Install

Requires Node.js 22.14 or later. Ships as ESM with compiled JavaScript and types.

npm install @erseco/code-snippets-client
import { CodeSnippetsClient } from "@erseco/code-snippets-client";

const client = new CodeSnippetsClient({
  baseUrl: "https://wordpress.example",
  auth: {
    type: "application-password",
    username: process.env.WP_USERNAME!,
    password: process.env.WP_PASSWORD!,
  },
});

const snippets = await client.list();
const snippet = await client.create({
  name: "Demo",
  code: "// PHP without <?php",
});
await client.update(snippet.id, { code: "// Updated code" });
// When you are ready to run it:
await client.activate(snippet.id);

New snippets are inactive by default. Updates preserve unspecified fields and remote activation state. single-use snippets are never implicitly rearmed. The library does not load .env, write backups or run Git commands.

CLI for developers and agents

The CLI uses the same client. It only reads the explicitly selected .env file; existing environment variables take precedence. No global installation needed.

npx wp-code-snippets list --env-file .env
npx wp-code-snippets diff 42 --file snippets/demo.php --env-file .env
npx wp-code-snippets push 42 --file snippets/demo.php --env-file .env --yes
npx wp-code-snippets create --name Demo --file snippets/demo.php --env-file .env --yes

Every write requires --yes; agents obtain authorization in the conversation. --dry-run previews the supplied fields without connecting to WordPress. It does not verify permissions, PHP syntax or remote conflicts. diff returns both code versions and whether they match. Output is JSON except for pull and help. Errors go to stderr and produce a nonzero exit code.

Set WP_USER_AGENT in the CLI environment file (or userAgent in client options) when your installation needs a custom HTTP User-Agent for login and REST. Set WP_TIMEOUT_MS=120000 (or timeoutMs: 120000) to allow two minutes per request on slow servers. The default is 30000 ms, including redirects and response reading. Values must be integers from 1 to 2147483647. No retries are added. See authentication configuration.

API and CLI reference · Authentication and CAS · Architecture and limits · Development and releases

Test

npm ci
npm run check
npm run test:package
npm run test:integration  # Docker required; starts and stops disposable WordPress

CI runs on Linux, Windows and macOS. WordPress integration covers PHP 8.3/8.4, the latest pinned patches of WordPress 6.9/7.0/7.1 and both Code Snippets 3.9.6 and the latest pinned plugin release. A fixed compatibility baseline additionally tests WordPress 6.9.5 with Code Snippets 3.9.6.

npm run test:cas tests Cassify 2.4.9 on that fixed baseline against the public pac4j CAS test server, using a disposable account. This opt-in external check is independent of required CI. Local CAS simulations remain part of the unit tests. Neither check certifies every CAS deployment or MFA.

Copyright (C) 2026 Ernesto Serrano.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed without any warranty. See LICENSE.

SPDX-License-Identifier: GPL-3.0-or-later.