devbrain 0.2.0

Local-first CLI to capture, search, and recall developer workflow (commands, errors, and fixes)
# devbrain

A local-first CLI that remembers your developer workflow: commands, errors, and fixes, so you never debug the same issue twice.

## Why devbrain?

You fix a bug.

Two weeks later, you hit it again.

You remember solving it, but not *how*.

You search history and logs, then waste time.

**devbrain solves that.**

It passively captures your workflow:

- commands you run
- errors you encounter
- fixes you apply

Then it makes searchable, structured, and reusable.

```bash
devbrain search auth
```

## Core Features

### Developer Memory

```bash
devbrain log "fixed auth bug by updating JWT secret"
devbrain log-error "ECONNREFUSED localhost:3000"
devbrain log-cmd "npm run dev"
```

### Search

```bash
devbrain search auth
devbrain search "auth error" --type error --since 1d
devbrain search backend --tag api
```

Supports:

- multi-word search
- tag-aware results
- time filtering
- type filtering
- ranked relevance

### Automatic Capture (Bash)

`devbrain` can log commands:

```bash
npm run dev
cargo build
git commit -m "fix"
```

No manual logging required.

### Tagging

```bash
devbrain log "fixed login bug" --tag auth --tag backend
devbrain search auth
devbrain timeline --tag backend
```

### Stats and Insights

```bash
devbrain stats
```

Example:

```text
Total entries: 120
Logs: 60
Commands: 45
Errors: 15
Top project: api
Top tags: backend, auth
```

### Session Tracking

Group commands by session:

```bash
devbrain session
```

Useful for reviewing a dev session.

### Cleanup and Export

```bash
devbrain cleanup
devbrain cleanup --older-than 7
devbrain export backup.json
devbrain import backup.json --merge
devbrain search auth --json
```

## Installation

```bash
cargo install devbrain
```

## Example Workflow

```bash
devbrain log "fixed JWT issue"
devbrain log-error "port already in use"
devbrain log-cmd "npm run dev"
devbrain search jwt
devbrain errors --recent
```

## Bash Integration

Add to `~/.bashrc`:

```bash
shopt -s histappend
export DEVBRAIN_SESSION_ID="${DEVBRAIN_SESSION_ID:-$(date +%s)}"

devbrain_capture() {
    local status=$?

    history -a
    history -n

    local cmd
    cmd=$(history 1 | sed 's/^ *[0-9]* *//')

    [[ -z "$cmd" ]] && return
    [[ "$cmd" == devbrain* ]] && return

    [[ "$cmd" == "$LAST_DEVBRAIN_CMD" ]] && return
    LAST_DEVBRAIN_CMD="$cmd"

    devbrain shell-log "$cmd" --status "$status" --session "$DEVBRAIN_SESSION_ID" >/dev/null 2>&1
}

PROMPT_COMMAND="devbrain_capture"
```

Apply changes:

```bash
exec bash
```

Notes:

- uses Bash history (`history -a`, `history -n`)
- works best with `shopt -s histappend`
- `shell-log` is internal, not for manual use

Disable auto capture:

```bash
export DEVBRAIN_DISABLE_SHELL_CAPTURE=1
```

## Storage

All data is stored locally:

```text
~/.devbrain/db.json
```

No cloud. No tracking. Private.

## Philosophy

Capture small things consistently over capturing everything imperfectly.

## What devbrain is

- developer workflow memory
- debugging aid
- command and error history
- local-first tool

## What devbrain is not

- note-taking app
- AI assistant
- full IDE plugin

## Tech Stack

- Rust
- clap (CLI)
- serde (storage)
- chrono (time)

## Roadmap

- smarter filtering
- improved shell integration
- better ranking
- plugin support (future)

## License

MIT

## Contributing

PRs welcome. Keep it simple and useful.