Skip to main content

The coding agent that remembers — AI coding assistant with persistent memory and error learning.

Project description

Nex AI — The Coding Agent That Remembers

A CLI-based AI coding agent that wraps the Anthropic Claude API with persistent project memory, error pattern learning, and codebase indexing.

Features

  • Persistent Memory — Remembers your project context, conventions, and architecture across sessions
  • Error Learning — Logs past mistakes and queries them before generating code to avoid repeating errors
  • Codebase Indexing — Uses tree-sitter to parse your codebase and select relevant context for each task
  • Interactive Chat — Multi-turn conversation mode with full tool access and persistent history
  • Smart Context Selection — Two-phase token budgeting with file-level TF-IDF ranking and signature-only fallback
  • Safety Layer — Detects destructive operations (rm -rf, DROP TABLE, force push) and requires confirmation
  • Git Integration — Creates isolated branches per task, shows diffs, and offers to commit

Installation

pip install nexcoder

Quick Start

# Initialize Nex in your project
nex init

# Set up your API key
nex auth

# Build the codebase index
nex index

# Run a one-shot task
nex "add a health check endpoint"

# Or start an interactive session
nex chat

# Check project status
nex status

Commands

Command Description
nex "task" Run a coding task
nex init Initialize .nex/ directory
nex index Build codebase index (.nex/index.json)
nex chat Start interactive chat session
nex status Show project stats
nex auth Configure API key
nex memory show View project memory
nex memory edit Edit project memory
nex rollback Undo last agent change
nex --dry-run "task" Preview without executing

How It Works

  1. Context Assembly — Loads project memory, error patterns, and relevant code into the prompt. Files are ranked by TF-IDF relevance, with top files included in full and remaining files as signature summaries.
  2. Agent Loop — Iterates: call Claude API → execute tools → feed results back, up to 25 iterations.
  3. Interactive Chatnex chat maintains a persistent conversation with the agent, accumulating context across turns. Useful for exploratory work, debugging, or multi-step tasks.
  4. Codebase Indexnex index parses your source files with tree-sitter, extracting function/class signatures for fast relevance search.
  5. Git Commit — Shows diff and offers to commit on an isolated branch.

Tools

The agent has access to 5 tools:

Tool Description
read_file Read file contents with line numbers
write_file Write content, creating directories if needed
run_command Execute shell commands (safety-checked)
search_files Regex search across the codebase
list_directory Recursive directory listing

Development

# Clone and install in editable mode
git clone https://github.com/nex-ai/nex-ai.git
cd nex-ai
pip install -e ".[dev]"

# Run tests
pytest

# Lint and format
ruff check src/ tests/
ruff format src/ tests/

# Type check
mypy src/nex/

Architecture

src/nex/
├── cli.py          # Typer CLI entry point
├── agent.py        # Core agent loop + ChatSession
├── api_client.py   # Anthropic API wrapper
├── planner.py      # Task decomposition (Haiku)
├── reviewer.py     # Independent code review
├── context.py      # Context assembly + token budgeting
├── safety.py       # Destructive operation detection
├── config.py       # Configuration management
├── memory/         # Persistent memory system
│   ├── project.py  # .nex/memory.md
│   ├── errors.py   # .nex/errors.db (SQLite)
│   └── decisions.py # .nex/decisions.md
├── indexer/        # Codebase indexing
│   ├── scanner.py  # File discovery
│   ├── parser.py   # tree-sitter AST parsing
│   └── index.py    # Index builder + TF-IDF search
└── tools/          # Agent tools (5 total)
    ├── file_ops.py # read_file, write_file
    ├── shell.py    # run_command
    ├── search.py   # search_files
    └── git_ops.py  # Git operations

Environment Variables

Variable Description Default
ANTHROPIC_API_KEY Anthropic API key (required)
NEX_MODEL Override default model claude-sonnet-4-20250514
NEX_MAX_ITERATIONS Max tool calls per task 25
NEX_DRY_RUN Default dry-run mode false
NEX_LOG_LEVEL Logging verbosity INFO

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexcoder-0.1.4.tar.gz (54.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexcoder-0.1.4-py3-none-any.whl (56.7 kB view details)

Uploaded Python 3

File details

Details for the file nexcoder-0.1.4.tar.gz.

File metadata

  • Download URL: nexcoder-0.1.4.tar.gz
  • Upload date:
  • Size: 54.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nexcoder-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4def6ba8de160a258bd9ac3f9445a4d1760e8ae3bd62334878f86647d8776841
MD5 92207b7a7f4bc030c2e9ed2d00f71c03
BLAKE2b-256 c5ea14f4da2c5022341eb236a8b9814bef7d5ed6f504389251a5558396ae4aad

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexcoder-0.1.4.tar.gz:

Publisher: publish.yml on ehntec/nex-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nexcoder-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: nexcoder-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 56.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nexcoder-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1496363b327653b1f7b7ff52f0e07f87e857acc2735241f12f9ad3aa7095fbb3
MD5 e53a64ed4a85ce1fa524ce1afbc16a26
BLAKE2b-256 6a4e54b652767863c71b7e774f6a22008b3d5bcbb3274e95dc121112a906d84d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexcoder-0.1.4-py3-none-any.whl:

Publisher: publish.yml on ehntec/nex-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page