codebase

Public

Forked from altra/codebase

23 Downloads

1 star

README

Codebase Plugin for LM Studio

An autonomous local codebase engineer. Understands your repository structure, plans changes before making them, edits files surgically, verifies every change, and remembers architecture decisions, conventions, and known bugs across sessions.

This is Claude Code inside LM Studio — fully local, zero telemetry, works on private and sensitive codebases.


What It Does

  • Repository understanding — walks your project, detects framework and language, maps modules, finds entrypoints
  • Symbol tracing — finds every definition and usage of a function, class, or variable across the codebase
  • Impact analysis — identifies all files that depend on a target before you touch it
  • Patch planning — generates ordered, file-by-file edit plans before any code changes
  • Surgical editing — targeted find-and-replace edits with exact string matching, not full rewrites
  • Verification loop — runs build, tests, and lint after every change; retries on failure
  • Persistent project memory — architecture notes, conventions, known bugs, and decisions survive across sessions

Installation

cd codebase-plugin
npm install
npm run build

Load the built plugin folder in LM Studio.


Configuration

FieldDefaultDescription
Project Root(blank)Default project directory. Can be set per-session via scan_repository.
Test Commandnpm testCommand to run tests. Used by run_verification_loop.
Build Commandnpm run buildCommand to build the project. Used by run_verification_loop.
Lint Command(blank)Optional lint command. Skipped if blank.
Max File Read Lines500Maximum lines returned per read_file call.
Memory Data Path~/codebase-memory/Directory for the SQLite project memory database.

Session Start

Every session begins with:

  • scan_repository — walk the project, detect framework, register to memory
  • load_project_context — restore prior architecture notes, conventions, bugs, commands
  • Summary of what's known, then ready to work

Tools

scan_repository (Effect)

Walk a project directory, detect framework and language, map source files by module, find entrypoints. Persists the project to memory. Call once per session.

trace_symbol (Effect)

Find all definitions and usages of a function, class, variable, or type using grep. Returns file paths, line numbers, and surrounding context. Call before editing any symbol.

find_impact_zone (Effect)

Find all files that import or reference a given file or symbol. Returns the blast radius of a change. Call before editing any file that others depend on.

read_file (Effect)

Read file content with optional line range. Returns content with line numbers, total line count, and truncation flag.

write_file (Effect)

Write or overwrite a file. Creates parent directories. For new files or full rewrites only — use apply_patch for targeted edits.

apply_patch (Effect)

Replace an exact string in a file with new content. Surgical edit that leaves everything else untouched. The oldContent must match verbatim.

run_verification_loop (Effect)

Run build, test, and/or lint commands. Returns structured pass/fail per command with stdout/stderr. Call after every file change. Do not declare done without a passing run.

generate_patch_plan (Scaffold)

Produce a structured implementation plan for a task. Returns a JSON plan with ordered steps, impacted files, and a verification command. No files are changed by this tool.

save_project_memory (Store-write)

Save a categorized note about the project to persistent SQLite storage.

CategoryWhat to save
architectureHow the system is structured, module responsibilities, data flow
conventionNaming patterns, file organization, style rules, import conventions
bugKnown unresolved issues with reproduction steps
commandUseful project-specific shell commands
decisionWhy something was built a certain way

load_project_context (Store-read)

Load all saved memory notes for a project. Filter by category or retrieve all. Returns framework, language, entrypoints, conventions, and notes.

delete_project_memory (Store-write)

Delete a stale or incorrect memory note by ID.

list_projects (Store-read)

List all projects in memory with framework, language, and last-updated timestamp.


Editing Workflow

scan_repository        → understand the project
load_project_context   → restore prior knowledge
trace_symbol           → find what's involved
find_impact_zone       → understand blast radius
generate_patch_plan    → produce ordered steps
read_file              → see the current state
apply_patch            → surgical edit
run_verification_loop  → verify the change
save_project_memory    → record what was learned

The plugin never edits without reading first, never patches without a plan, and never declares done without a passing verification.


Framework Detection

The plugin detects frameworks from file structure and manifest signals:

FrameworkDetection signal
Next.jsnext.config.*, pages/, app/
Reactreact in deps, .jsx/.tsx files
FastAPIfastapi, uvicorn, @app.get
Djangomanage.py, settings.py
Expressexpress, app.listen
Rust/CargoCargo.toml, fn main()
Gogo.mod, func main()

Falls back to dominant file extension if no framework is detected.


Example Sessions

Bug fix:

"The auth middleware is returning 403 for valid tokens"

scan_repository → load_project_context → trace_symbol("authMiddleware") → find_impact_zone("middleware/auth") → generate_patch_plan → read_file → apply_patch → run_verification_loop

New feature:

"Add rate limiting to the /api/search endpoint"

generate_patch_plan → per-step read_file + apply_patch → run_verification_loop → save_project_memory(category="architecture", "Rate limiting applied via express-rate-limit on /api/search, configured in middleware/rateLimit.ts")

Onboarding a new project:

"I just cloned a new repo, help me understand it"

scan_repository → returns framework, language, module map, entrypoints, detected scripts → summary of architecture → save_project_memory for any non-obvious patterns found