Try it in the browser
Section titled “Try it in the browser”Open Change the priority of queued work and click Run. The queue moves the layout task to the front when its priority changes, then returns it first.
Install from source
Section titled “Install from source”Knotkit is preparing its first npm release. To use it in your project today, build a package tarball from a checkout. You’ll need Bun to build it and npm to pack it.
git clone https://github.com/jkomyno/knotkit.gitcd knotkitbun install --frozen-lockfilebun run buildnpm pack ./packagesIn your project, install the tarball using its absolute path. Use the filename printed by npm pack.
npm install /path/to/knotkit/knotkit-0.1.0.tgzKnotkit is ESM only. With TypeScript, use 5.x or later and set moduleResolution to "bundler" or "nodenext".
Browsers with ES2024 support. Import the same module in your browser bundle and on the server.
Import one module
Section titled “Import one module”Import the capability you need directly from a subpath such as knotkit/heap, knotkit/bitset, or knotkit/sampling.
Your bundler can start from that subpath and include its dependencies.
import { minBinaryHeap, numberOrder } from 'knotkit/heap'
const heap = minBinaryHeap(numberOrder, [30, 1, 50, 20])
heap.peek() // 1heap.pop() // 1heap.size // 3minBinaryHeap creates a heap, and numberOrder tells it how to compare numbers. Orderings, random sources, and hash
functions are inputs to the operations that need them, so you can replay a workload with the same inputs.
Choose a module lists every task the modules solve. Search it for what you are trying to do.
Handle errors
Section titled “Handle errors”Use the exported error class and its code to handle a specific failure. Calling pop() on an empty heap raises
HeapInvalidInputError with the code EMPTY.
import { HeapInvalidInputError, minBinaryHeap, numberOrder } from 'knotkit/heap'
const empty = minBinaryHeap(numberOrder)
try { empty.pop()} catch (error) { if (!(error instanceof HeapInvalidInputError) || error.code !== 'EMPTY') { throw error } // Handle the empty heap.}Each module page lists its error codes. Conventions covers errors, layouts, and seeding in one place.
Set up your coding agent
Section titled “Set up your coding agent”Paste this into Claude Code, Cursor, Codex, or any agent that can run commands:
Set up Knotkit in this project.
1. Follow https://knotkit.jkomyno.dev/getting-started.md#install-from-source to build and install the package. Use "bundler" or "nodenext" module resolution in TypeScript.
2. Run `npx skills add jkomyno/knotkit --skill knotkit-select` to install the skill that picks a module for a task.
3. Add this to AGENTS.md (or CLAUDE.md):
Knotkit: pick a module from node_modules/knotkit/capabilities.json, then read node_modules/knotkit/<name>/README.md. Import from 'knotkit/<name>'; there is no root import. Create structures with the exported factory functions, branch on error.code, and pass seeds and orderings explicitly.
If something is unclear, read https://knotkit.jkomyno.dev/llms.txt.Where to go next
Section titled “Where to go next”- Choose a module when you know the task and want to find the right data structure.
- Run a guide for a small example you can adapt to your project.
- Read the module reference for operation costs, layout choices, and API signatures.