Neurobyte
by Allostan Labs
Neurobyte is a developer tool designed to optimize Jupyter Notebooks for AI-driven development. It acts as a middleware between your messy experimental notebooks and your LLM's context window.
By sanitizing, auditing, and formatting your code before you paste it into an LLM (or send it via API), you reduce hallucinations, save context tokens, and improve the quality of generated code.
Why Neurobyte?
- Reduce Noise: Strip magic commands (
%sql,!pip), progress bars, and massive outputs that confuse models usingneurobyte export --clean. - Prevent Errors: Audit your notebook for non-reproducible patterns (absolute paths, hidden states) before asking an AI to refactor it.
- Optimize Context: Hoist imports to the top and format code with
ruffso the LLM parses dependencies immediately.
Installation
pip install neurobyte
# OR
pip install "neurobyte[all]"
Core Workflow
Neurobyte follows a Audit → Format → Export workflow to ensure high-quality context.
1. Audit: Health Checks for Notebooks
The audit command analyzes your notebook for issues that typically degrade LLM performance or cause hallucinated fixes.
neurobyte audit my_notebook.ipynb
What it checks:
- Reproducibility: Flags
!pip installand hardcoded absolute paths (/Users/pedro/...). - Cyclomatic Complexity: Identifies "spaghetti code" cells (complexity > 10) that should be refactored before asking for changes.
- Execution Order: Warns if cells were run out of order (e.g., cell 10 run before cell 5), which creates hidden state bugs.
- Secrets: Scans for potential leaked API keys (
api_key="sk-..."). - Output Size: Flags cells with massive text outputs (>5000 chars) that waste tokens.
2. Format: Token Optimization
The format command standardizes your code to make it easier for models to understand.
neurobyte format my_notebook.ipynb --hoist
Features:
- Ruff formatting: Applies standard Python formatting to all code cells.
- Import Hoisting (
--hoist): Extracts allimportstatements from scattered cells and consolidates them into a single top-level "Setup" cell.- Why? LLMs perform better when they see dependencies upfront.
3. Export: Context Preparation
The export command is the final step. It converts your notebook into an LLM-ready text representation.
neurobyte export my_notebook.ipynb --output-format xml
Options
-
Output Formats:
txt(default): Minimalist representation, distinct headers.xml: Structured format (<cell>...) ideal for Claude/Anthropic prompts.json: Full metadata preservation.
-
Cleaning features:
--strip-magics: Removes IPython specific syntax (%timeit,!ls) that causes syntax errors in standard Python scripts.--clear-output: Removes all graph/text outputs. Useful when you only want the code logic reviewed.--redact-secrets: Automatically replaces API keys with[REDACTED].
-
Selective Export:
--include-markdown: Include documentation text.--max-cells 50: Limit context size.
Example: The "Perfect Context" Pipeline
# 1. Clean up the code structure
neurobyte format analysis.ipynb --hoist
# 2. Check for issues
neurobyte audit analysis.ipynb
# 3. Export a clean, code-only version for your prompt
neurobyte export analysis.ipynb \
--strip-magics \
--clear-output \
--output-format xml \
--outfile context.xml
Configuration
You can persist your preferences in pyproject.toml:
[tool.neurobyte]
redact_secrets = true
extra_redact_patterns = [
"internal_project_id",
]
[tool.neurobyte.export]
output_format = "xml"
strip_magics = true
include_markdown = false
Metadata
Release files for neurobyte 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| neurobyte-0.2.3.tar.gz | 26.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| neurobyte-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.9 kB
Release files / neurobyte-0.2.3.tar.gz
| Download URL | neurobyte-0.2.3.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7671766a75f34840eafc5f7c8bdcf23c6ba557796d81956a8c215d52562ec511
|
|
BLAKE2b-256 checksum How to use checksums |
6d850b7f9112b59278983e658a735d01a1444cbab520643d6ad8135fee814d48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.7
|
Release files / neurobyte-0.2.3-py3-none-any.whl
| Download URL | neurobyte-0.2.3-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96a9d194c01f3639911d0b2ee98db8015e168bedff23132553d76b779f382b3a
|
|
BLAKE2b-256 checksum How to use checksums |
8b1a3bf953b53346c04cf343d1b118a52ddf2ade0ae9c00aa8229faa05499639
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.7
|