This guide will walk you through setting up CodeNERD for a Python project (like ArangoRDF). CodeNERD treats your code as a "Glass Box," indexing it into a knowledge graph and allowing it to safely execute code in sandboxed Docker containers.
- CodeNERD CLI Installed: Ensure you have built the
nerdbinary. - Docker Running: CodeNERD uses Docker to spin up ephemeral environments for your Python code.
- Python Project: A standard Python project with
requirements.txt,setup.py, orpyproject.toml.
Navigate to your Python project root.
cd ~/my-python-project
nerd initWhat happens:
.nerd/directory created: Stores the local database and configuration.- Indexing: CodeNERD parses all your
.pyfiles using Tree-sitter to understand classes, functions, and imports. - Fact Generation: It creates a highly detailed "symbol graph" of your code.
- Vector Embeddings: It generates embeddings for your code to enable semantic search.
Launch the TUI (Text User Interface):
nerdYou are now in a chat session with the agent. The agent has context of your entire codebase.
You: "Explain how the GraphConnection class works and where it is instantiated."
Agent: Will query its internal knowledge graph (Mangle) to find symbols and cross-references, then explain it to you.
You: "Rename the connect method to establish_connection and update all callers."
Agent:
- Identifies all references.
- Proposes a plan.
- Generates a diff.
- Asks for your approval (
/approve).
You: "Run the tests for the connection module." Agent:
- Spins up a Docker container mirroring your environment.
- Installs dependencies (from
requirements.txt). - Executes
pytestinside the container. - Reports usage and results back to you.
One of CodeNERD's strongest features for Python is Sandboxed Execution. It doesn't run code on your host machine.
When you ask it to "Run tests" or "Verify this fix":
- It creates a Docker container tagged
nerd-python-<repo>. - It mounts your code (or clones it).
- It creates a virtual environment inside the container.
- It executes the command.
This means you can let the agent iterate on fixes without worrying about it messing up your local environment.
"No tests found"
- Ensure you have
pytestinstalled in your project. - Check that your test files usually follow
test_*.py.
"Docker error"
- Make sure Docker Desktop (or engine) is running.
- Run
docker psto see if CodeNERD containers are active.