Documents › Developer Guide
This document is a quick reference for maintainers and frequent contributors. It complements the contributor guide (which is contributor-facing) and contains deeper, actionable instructions for setting up, testing, and developing the project.
# clone
git clone https://github.com/cashubtc/cashu-ts.git
cd cashu-ts
# install exact dependencies used by CI
npm ci
# prepare browser dependencies for integration tests (one-time)
npm run test:prepare
# opt in to local hooks (optional)
npm run setup-hooks
Developing branch
Please develop new features against the development branch (v3). After cloning, switch to it and pull the latest changes:
# switch to the development branch for v3 work
git checkout development
git pull
If you are backporting fixes to the v2 line, use the dev-v2 branch instead.
Notes:
npm ci requires a package-lock.json and produces a reproducible node_modules tree.package.json (engine: node >=22.4.0). Use nvm, volta, or asdf to pin your local Node version.npm ci after switching major branchesWhen switching between major branches (for example development for v3 and dev-v2 for v2) the lockfile and installed dependencies can differ. This frequently causes confusing failures when compiling or running api-extractor.
Always run a clean install after switching major branches to ensure node_modules matches the checked-in lockfile:
# after checkout
npm ci
If you still see strange build or extractor errors, do a full refresh of dependencies:
rm -rf node_modules
npm ci
This callout is important — please don't skip it when moving between major branches, it saves a lot of time debugging mysterious build/test failures.
npm (node package manager), git, optional nvm/volta for Node version management.npm run test:prepare).Layout
scripts/hooks/ (kept non-executable in the repo).githooks/ (ignored by git; created by scripts/install-git-hooks.sh)scripts/hooks/* -> .githooks/git config --local core.hooksPath .githooksWhy this pattern
Useful commands
# opt-in (makes and runs the installer)
npm run setup-hooks
# undo opt-in (revert to default hooks path)
# NOTE: removing the installed hooks directory is destructive. The uninstall
# script unsets the local hooks path by default. To also remove the
# `.githooks/` directory set the guard variable explicitly to avoid an
# accidental `rm -rf`:
# unset hooks path only
npm run uninstall-hooks
# unset hooks path AND remove installed hooks (explicit opt-in)
REMOVE_GITHOOKS=1 npm run uninstall-hooks
Authoring hooks
scripts/hooks/ and keep them POSIX-friendly where possible.CONTRIBUTING.md and consider adding tests or examples.pre-commit: quick feedback (lint + format) — fast to avoid blocking developers.
FULL_PRECOMMIT=1 for a single commit when you want the full suite locally.pre-push: runs full PR checks (npm run prtasks) to ensure the full suite runs before pushing.This keeps commits fast while ensuring pushes execute the heavier checks.
The repo includes a convenience script:
npm run prtasks
This runs (in order): lint, format, api:update (compile + api-extractor), tests, and git status.
Caution: api:update can modify generated files (e.g. API reports). Inspect and commit any intended changes.
Many maintainers prefer to run the full PR checks locally before pushing. A common, reliable workflow:
examples/auth_mint/docker-compose.yml:# from the repo root
docker compose -f examples/auth_mint/docker-compose.yml up -d
npm run prtasks
npm run test-integration
3a. (Optional but recommended) Run the consumer smoke tests used by CI:
# runs all consumer smoke tests (bundler, commonjs, iife, nodenext, reactnative)
npm run test:consumer
Note: the consumer smoke tests are run in CI but are intentionally not part of prtasks to avoid adding noise to every local run; running npm run test:consumer locally before pushing helps reproduce CI behavior.
The test:consumer aggregator runs the following scripts (you can run them individually):
npm run test:bundler — smoke test using the bundler consumernpm run test:commonjs — smoke test for CommonJS consumersnpm run test:iife — smoke test for IIFE (standalone) buildnpm run test:nodenext — smoke test for Node ESM consumersnpm run test:reactnative — smoke test for React Native consumerRun the individual script if you want to isolate failures or speed up debugging.
docker compose -f examples/auth_mint/docker-compose.yml down
This pattern (run npm run prtasks and integration tests against a local mint) gives fast, reproducible results and avoids surprises in CI.
The repository provides Makefile targets that make it easy to spin up the most popular cashu mints (currently cdk and nutshell). These are used in the CI for integration testing and made available locally. Use the Makefile as the single source of truth for the pinned Docker image versions.
Spin up / tear down locally
# start the mint (uses Makefile defaults unless you override)
DEV=1 make cdk-up
# stop the mint
DEV=1 make cdk-down
# start nutshell
DEV=1 make nutshell-up
# stop nutshell
DEV=1 make nutshell-down
# run a specific mint image with a custom container name
CDK_IMAGE=cashubtc/mintd:0.13.4 CDK_NAME=my-local-mint DEV=1 make cdk-up
make cdk-up / make nutshell-up) so the runtime behavior in CI matches local usage.latest) so PRs will update numeric tags.npm run test-integration.npm cinpm run test:prepareDEV=1 make cdk-up (and/or DEV=1 make nutshell-up)npm run test-integrationDEV=1 make cdk-down / DEV=1 make nutshell-downnpm run api:check to create a temporary API report and compare it to the recorded status-quo at /etc/cashu-ts.api.md.npm run api:update to update the /etc status-quo when a public API change is intended.When running api:update locally:
npm run api:update
# inspect changes under /etc
git add /etc/cashu-ts.api.md
git commit -m "docs(api): update API report"
If api:update modifies generated code or types, run the test/build steps and ensure CI passes.
Run unit tests (node + browser) locally:
npm test
The npm test script runs Vitest with coverage enabled (--coverage) and emits reports
into the coverage/ directory.
After the run you can open the HTML report locally (coverage/index.html) in
your browser to inspect per-file metrics.
CI also publishes code coverage; the project site hosts the latest report (see the README badge/link for the public report).
If a test requires Node-only features, name the file with .node. in the filename
(for example cbor.node.test.ts). The Vite/Vitest configuration will then
skip browser testing for that file and run it only in the Node environment.
Likewise, you can use .browser. in the filename to mark a test as
browser-only (we currently don't have any browser-only tests, but the convention is supported).
Run only node tests or a single test file with vitest (useful for rapid iteration):
npx vitest --run --filter <pattern>
npm run test:prepare
# then run the integration tests
npm run test-integration
If tests are flaky locally, run with increased verbosity or use --run --inspect / --watch where supported.
npm install <pkg> --save
# or for dev dependencies
npm install <pkg> --save-dev
package-lock.json (CI will use that exact lockfile).npm ci.Cashu-TS uses semantic versioning. The repository maintains a development branch for the current major (v3) and a dev-v2 branch for critical fixes to the v2 line.
Guidelines:
development branch.dev-v2 (do not mix both in a single PR).Releases should be done by the robots, inside the workflow files. However, here are the release steps for manual flow.
Release steps (manual flow):
git checkout development && git pull — ensure development is up to datenpm version <major | minor | patch> — create a new release commit & taggit push && git push --tags — push commit and taggit checkout main && git pull && git merge <tag> — merge the tag into mainNote: increment the major if there are breaking API changes. Otherwise increment the minor for new features and patch for hotfixes.
If you see strange compile or api-extractor errors after switching branches: run npm ci to ensure node_modules matches the checked-in lockfile. If problems persist, try removing node_modules and running npm ci again.
To reproduce CI locally (fast): run npm run prtasks. This runs the same suite used for PRs and helps surface issues that CI would catch.
Feel free to join the matrix server or telegram channel