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.6.tar.gz (56.8 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.6-py3-none-any.whl (58.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nexcoder-0.1.6.tar.gz
  • Upload date:
  • Size: 56.8 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.6.tar.gz
Algorithm Hash digest
SHA256 5873b668278525e98d9ccc2127d777482f39b8454d993b1cf59c5cf7ffa9f805
MD5 5f2f32ec68e738770a1ca4c75976fe31
BLAKE2b-256 8444682cf08414ce75d64e7e55fdba494693c93f7a912bc96aa1171f2b664c07

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexcoder-0.1.6.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.6-py3-none-any.whl.

File metadata

  • Download URL: nexcoder-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 58.3 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2c45b7bc909b4068a9db3a8ff3dd63bee4dcd2a285d7d133840fc99aeeb99c03
MD5 39f749a356c42f6ed2d4c2418bd409d1
BLAKE2b-256 d27c65d95b224f818194f9c987c6e7c1fe0f7e3bb74d0e902fd9094c11fb7cbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexcoder-0.1.6-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