Skip to content

shahidcodes/neuron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neuron

Local-first coding taste learner. Extracts your coding style from git history using small models (3B–14B parameters). All processing stays on your machine.

An open-source alternative to CommandCode's taste feature.


What is "taste"?

Every developer builds up years of micro-decisions: how they name variables, when they extract helpers, which patterns they reach for, how they structure tests. This accumulated intuition is your coding taste.

Most AI coding agents ignore it. They generate statistically average code. You fix it. They don't learn. You fix it again.

Neuron solves this by:

  1. Observing your actual code changes from git history
  2. Extracting patterns using a small local model
  3. Enforcing those patterns by injecting them into your agent's context

Prerequisites

Option A: Ollama (recommended, fully local)

  1. Install Ollama: https://ollama.com
  2. Pull a small coding model (pick one):
# Best balance of speed and quality (4.7GB)
ollama pull qwen2.5-coder:latest

# Ultra-fast, surprisingly capable (2.0GB)
ollama pull llama3.2:3b

# Strong reasoning (9.1GB)
ollama pull phi4:14b
  1. Verify it's running:
ollama list

Option B: OpenRouter (cloud, cheap)

  1. Get an API key at https://openrouter.ai
  2. Set it as an environment variable:
export NEURON_API_KEY="sk-or-v1-..."
export NEURON_BACKEND="openrouter"
export NEURON_MODEL="qwen/qwen-2.5-7b-instruct"

Installation

From npm (when published)

npm i -g neuron

From source (today)

git clone https://github.com/shahidcodes/neuron.git
cd neuron
npm install
npm run build
npm link        # makes `neuron` available globally

To update later:

cd neuron
git pull
npm run build

Quick Start

Step 1: Learn your taste

Inside any git repository:

cd ~/my-project
neuron learn

This will:

  • Analyze your last 200 commits (configurable)
  • Extract up to 50 diff signals
  • Run them through your local model
  • Generate .neuron/taste.md

Expected output:

✔ Extracted 47 signals from 83 commits
Using model: qwen2.5-coder:latest (ollama)
✔ Generated taste for 6 categories
✔ Merged: +12 new, ~3 updated, -1 removed, =8 unchanged
✔ Taste written to .neuron/taste.md

✓ Taste learned successfully

# TypeScript
  - Use strict mode (0.92)
  - Prefer type imports for type-only dependencies (0.88)
  - Use explicit return types on exported functions (0.75)

# CLI Conventions
  - Use Commander.js for CLI tools (0.85)
  - Use lowercase single-letter flags (-v, -h) (0.82)

# Testing
  - Use Vitest instead of Jest (0.90)
  - Group tests by feature area (0.71)

Step 2: Apply to your agent

Claude Code:

neuron apply claude-code

This writes taste into two places:

  • .claude/projects/<name>/memory/taste.md — Claude Code's memory system
  • CLAUDE.md — Project instructions

Restart Claude Code to pick it up.

Cursor:

neuron apply cursor

This appends taste to .cursorrules.

Any other agent:

neuron apply generic

Copy-paste the printed taste into your agent's custom instructions.


Commands Reference

neuron learn [source]

Learn taste from git history.

neuron learn                          # Current directory, default 200 commits
neuron learn /path/to/repo            # Specific repo
neuron learn --max-commits 500        # Analyze more history
neuron learn --max-signals 100        # Extract more signals
neuron learn --author "John Doe"      # Only your commits
neuron learn --branch develop         # Specific branch
neuron learn -g                       # Store in global taste (~/.neuron/)

neuron apply <agent>

Inject taste into an agent.

neuron apply claude-code              # Claude Code
neuron apply cursor                   # Cursor
neuron apply generic                  # Print for manual use
neuron apply claude-code -g           # Use global taste

neuron list

List available taste packages.

neuron list                           # Project + global
neuron list -g                        # Global only

neuron lint

Validate taste file format.

neuron lint
neuron lint -g

neuron update

Incremental update from recent commits.

neuron update                         # Last 50 new commits
neuron update --max-commits 20       # Fewer commits

Configuration

Environment Variables

Variable Default Description
NEURON_MODEL qwen2.5-coder:latest Model name
NEURON_BACKEND ollama ollama or openrouter
OLLAMA_HOST http://localhost:11434 Ollama server URL
NEURON_API_KEY API key for OpenRouter
NEURON_API_URL Custom API endpoint

Per-command model override

neuron learn --model llama3.2:3b
neuron learn --model qwen3.5:latest

How It Works

1. Signal Extraction

Neuron runs git log and git show to extract code changes:

  • Collects commits by author (ignores bots, merge commits, reverts)
  • Extracts substitutions — pairs of removed/added code
  • Filters noise — skips lockfiles, minified code, dist folders
  • Groups patterns — identical changes across multiple files get grouped
  • Infers categories — imports, types, testing, logging, error-handling, code-style

2. Small Model Processing

Signals are sent to a small model in a two-stage pipeline:

Stage 1: Extract raw patterns

"Analyze these 12 diff signals and output JSON patterns"

Stage 2: Refine into taste rules

"Convert patterns into formal rules: - Preference. Confidence: 0.85"

This works reliably even with 3B parameter models because the task is highly structured.

3. Storage & Merging

Taste is stored in .neuron/taste.md:

---
generatedAt: 2026-05-22T10:00:00Z
model: qwen2.5-coder:latest
commitsAnalyzed: 83
signalsExtracted: 47
---

# TypeScript
- Use strict mode. Confidence: 0.92
- Prefer type imports for type-only dependencies. Confidence: 0.88

When you run neuron learn again:

  • New rules are merged with existing taste
  • Confidence scores are updated using weighted averaging
  • Old rules decay by 5% per month if not seen
  • Rules below 0.30 confidence are removed

4. Injection

Taste is injected into agent context as system instructions. The agent doesn't "train" on your taste — it reads it as rules before generating code.


Taste File Format

Human-readable markdown with YAML frontmatter:

---
generatedAt: 2026-05-22T10:00:00Z
model: qwen2.5-coder:latest
source: git-history
commitsAnalyzed: 83
signalsExtracted: 47
categories:
  - typescript
  - cli
  - testing
---

# TypeScript
- Use strict mode. Confidence: 0.92
- Prefer explicit return types on exported functions. Confidence: 0.75

## Imports
- Use type imports for type-only dependencies. Confidence: 0.88
- Prefer named exports over default exports. Confidence: 0.85

# CLI Conventions
- Use Commander.js for CLI tools. Confidence: 0.85
- Use lowercase single-letter flags (-v, -h, -q). Confidence: 0.82
- Start versions at 0.0.1. Confidence: 0.78

# Testing
- Use Vitest instead of Jest. Confidence: 0.90
- Group tests by feature area. Confidence: 0.71

You can edit this file directly. Neuron will merge your manual edits on the next run.


Storage Locations

Location Purpose
.neuron/taste.md Project-specific taste
~/.neuron/taste.md Global taste (cross-project)
commandcode.ai/... Not used — Neuron is fully local

Use -g flag for global operations:

neuron learn -g          # Learn global taste
neuron apply claude-code -g   # Apply global taste

Comparison with CommandCode Taste

Feature CommandCode Neuron
Signal source Git history + session interactions Git history (session coming soon)
Model Proprietary taste-1 server Your local Ollama model
Privacy Processes on their servers 100% local
Cost Subscription Free (after Ollama setup)
Taste format .commandcode/taste/ .neuron/taste.md
Sharing npx taste push/pull Git-based (future)

Troubleshooting

"No signals extracted"

  • Are you in a git repository? Run git status
  • Does the repo have commits with actual code changes? Root commits and add-only commits produce fewer signals
  • Try neuron learn --max-commits 500 to analyze more history

"Ollama error: model not found"

ollama pull qwen2.5-coder:latest

Or set a different model:

export NEURON_MODEL="llama3.2:3b"

"Ollama error: connection refused"

Ollama might not be running:

ollama serve

Or set a remote Ollama host:

export OLLAMA_HOST="http://your-server:11434"

Taste rules are too generic

The model needs more signals to learn real patterns. Run on a repo with more diverse commits, or increase --max-signals.


Roadmap

  • Git signal extraction
  • Small model processing (Ollama/OpenRouter)
  • Taste storage & merging
  • Claude Code injection
  • Cursor injection
  • Session-based learning (post-agent diff analysis)
  • Team taste sharing via git
  • VS Code extension
  • Custom prompt templates

License

MIT

About

Local-first coding taste learner using small models

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors