nblibram
The notebook Swiss Army knife—query, edit, and sanitize Jupyter files from the shell. Treats notebooks as structured documents so agents and humans can slice, mutate, and clean them without a GUI. Secret detection is powered by gitleaks (222+ built-in rules for API keys, tokens, credentials, etc.). Ships as a single Go binary with no runtime dependencies.
Philosophy
Notebooks are computational narratives—code cells don't stand alone, they're explained by the Markdown cells around them.
nblibram's query operations slice Markdown/code cell pairs together so the surrounding story always travels with the code.
section slices by heading hierarchy, cells slices by cell order, both preserving the narrative context that makes code understandable.
Commands (stdin → stdout)
All commands read .ipynb JSON from stdin (or --file) and write to stdout.
Query commands apply gitleaks-based privacy filters by default (--no-filter to disable).
Query
nblibram toc– heading structure with preview (--words,--format md|json).nblibram section– cells under a heading, including nested subsections (--sets,--format md|json|py).nblibram cells– consecutive cells from a matched position (--count N), or Markdown+code pairs (--sets N).nblibram outputs– cell outputs (--format text|json|raw,--mime).
Mutate
nblibram insert– insert a cell (--query,--position before|after,--type code|markdown,--source).nblibram update– replace cell content (--query,--source,--hashrequired).nblibram delete– remove a cell (--query,--hashrequired).
Mutation commands write the modified notebook JSON to stdout. Use -i for in-place file update.
--hash enforces optimistic locking—obtain it via nblibram hash.
Filter & Audit
nblibram filter– sanitize sensitive information in a notebook (-ifor in-place).nblibram audit– check for leaked secrets without modifying the notebook. Exits 1 if leaks are found (--format text|json).
Both use gitleaks' built-in rules by default. Set NBLIBRAM_GITLEAKS_CONFIG to a .gitleaks.toml path to add custom rules (e.g. IP addresses, domain names, internal URLs).
Utility
nblibram hash– compute djb2 hashes for cells (--queryor--all).nblibram pkl– read pickled kernel output logs (--file,--format json|text).
Queries
Use --query TYPE:VALUE to locate cells. Multiple --query flags are ANDed.
start:37– absolute cell index.match:"pattern"– regex against cell content.contains:"text"– substring match.id:abc123– Jupyter cell_id.meme:UUID– nblineage meme ID. Trailing*for prefix match (e.g.meme:642f96e0*matches branched cells).
Examples
# Table of contents
nblibram toc --format json < notebook.ipynb
# Extract a section
nblibram section --query match:"## Setup" --sets 2 < notebook.ipynb
# Get 5 consecutive cells starting from index 10
nblibram cells --query start:10 --count 5 --format py < notebook.ipynb
# Extract output as PNG
nblibram outputs --query id:plot-cell --format raw --mime image/png < notebook.ipynb > plot.png
# Insert a cell, then sanitize
nblibram insert --query start:0 --source 'x = 1' < notebook.ipynb | nblibram filter > clean.ipynb
# Delete with optimistic locking
HASH=$(nblibram hash --query start:3 < notebook.ipynb | jq -r '.[0]._hash')
nblibram delete --query start:3 --hash "$HASH" -i notebook.ipynb
# Audit for secrets (CI-friendly, exits 1 on findings)
nblibram audit < notebook.ipynb
# Audit with JSON output
nblibram audit --format json < notebook.ipynb
# Read a pickled kernel log
nblibram pkl --file output.pkl --format text
Getting started
Install with pip
pip install nblibram
Wheels include the executable and install the nblibram command in your Python
environment. Go is not required.
Standalone binary
Download the latest binary from Releases and place it in your $PATH:
# macOS (Apple Silicon)
curl -sL https://github.com/NII-cloud-operation/nblibram/releases/latest/download/nblibram_darwin_arm64.tar.gz | tar xz
mv nblibram /usr/local/bin/
# macOS (Intel)
curl -sL https://github.com/NII-cloud-operation/nblibram/releases/latest/download/nblibram_darwin_amd64.tar.gz | tar xz
mv nblibram /usr/local/bin/
# Linux (amd64)
curl -sL https://github.com/NII-cloud-operation/nblibram/releases/latest/download/nblibram_linux_amd64.tar.gz | tar xz
sudo mv nblibram /usr/local/bin/
Build from source
go build ./cmd/nblibram/
Configuration
nblibram uses gitleaks for secret detection. By default, gitleaks' 222+ built-in rules are active.
To add custom rules (e.g. IP addresses, internal URLs), create a .gitleaks.toml and point to it:
export NBLIBRAM_GITLEAKS_CONFIG=/path/to/.gitleaks.toml
Example .gitleaks.toml:
[extend]
useDefault = true
[[rules]]
id = "ipv4-address"
description = "Detects IPv4 addresses"
regex = '''\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b'''
[rules.allowlist]
regexes = [
'''192\.168\.\d{1,3}\.\d{1,3}''',
'''127\.0\.0\.1''',
'''0\.0\.0\.0''',
]
[[rules]]
id = "email-address"
description = "Detects email addresses"
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'''
[rules.allowlist]
regexes = [
'''.*@example\.com''',
]
Detected secrets are replaced with [rule-id_N] labels, preserving equivalence (e.g. the same secret always maps to [generic-api-key_1]).
Metadata
Release files for nblibram 2026.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| nblibram-2026.10.0-py3-none-win_arm64.whl | Python 3 | none | Windows ARM64 | Details |
| nblibram-2026.10.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| nblibram-2026.10.0-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| nblibram-2026.10.0-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| nblibram-2026.10.0-py3-none-macosx_13_0_x86_64.whl | Python 3 | none | macOS 13.0+ x86-64 | Details |
| nblibram-2026.10.0-py3-none-macosx_13_0_arm64.whl | Python 3 | none | macOS 13.0+ ARM64 | Details |
Total release size: 23.6 MB
Release files / nblibram-2026.10.0-py3-none-win_arm64.whl
| Download URL | nblibram-2026.10.0-py3-none-win_arm64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
fbe2693a7c66d4d0786d9e9c0a851695b474009f2dc2ba386165512688f165b7
|
|
BLAKE2b-256 checksum How to use checksums |
6f86b6110716e4e956c6b3cd0836a25f7c198cb85b621721cbe1c8578dc55698
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / nblibram-2026.10.0-py3-none-win_amd64.whl
| Download URL | nblibram-2026.10.0-py3-none-win_amd64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
055c2dcac9f1672b7d4f101f932bad3b1bb7a30c315537a11d68339024820d66
|
|
BLAKE2b-256 checksum How to use checksums |
b7779f5d8b84a44a264cbfc8da220176049e2d5822b67da20596980f29cea33a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / nblibram-2026.10.0-py3-none-manylinux_2_17_x86_64.whl
| Download URL | nblibram-2026.10.0-py3-none-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 4.1 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
8d5e03439f482e752698d67cea4e913ea44bf589bbd6dc2382d8ab186c7b61d0
|
|
BLAKE2b-256 checksum How to use checksums |
f42827cb7833ea37f0349c41ec09db43902db84f2c656ccd0cecf0dd4eaa4115
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / nblibram-2026.10.0-py3-none-manylinux_2_17_aarch64.whl
| Download URL | nblibram-2026.10.0-py3-none-manylinux_2_17_aarch64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
ef94c39f4711df59bd8e41864a796c2781f87dbd1a03569f601ec8d4f2adfb95
|
|
BLAKE2b-256 checksum How to use checksums |
a23cc27bab7ad092e55447b766c0e07bbf19262bb406322d3bba3fef944cd03d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / nblibram-2026.10.0-py3-none-macosx_13_0_x86_64.whl
| Download URL | nblibram-2026.10.0-py3-none-macosx_13_0_x86_64.whl |
|---|---|
| Size | 4.1 MB |
| Tags | Python 3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
a87281c875a050260ed386e53a0e66d7506a40c74f4d697b0155945206fb872f
|
|
BLAKE2b-256 checksum How to use checksums |
a4d7f2de7a2dfb329da91cb9acc690036d8ca99ccac838abe71107fd00c3f8cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / nblibram-2026.10.0-py3-none-macosx_13_0_arm64.whl
| Download URL | nblibram-2026.10.0-py3-none-macosx_13_0_arm64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | Python 3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e69acb8b87e79c0adb23b0508e094d0666eeacd742596c56f0512a687e860cd6
|
|
BLAKE2b-256 checksum How to use checksums |
b1a02c606f1fff22a7f3359e1271ae9937ed378358d1582d3c39758685d43dd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency log