# Koder 4000 (K4000)

AI-assisted feature development and code review system using MCP (Model Context Protocol).

## What is K4000?

K4000 helps LLMs create well-defined software features through a structured workflow:

1. **Feature Analysis** - Takes a feature description, analyzes it for gaps, and generates clarifying questions
2. **Q&A Session** - Humans answer questions to refine the feature specification
3. **Implementation** - Following TDD principles, tests and code are written
4. **Code Review** - Automated review from 5 perspectives with iterative feedback

## How to install and use


```bash
cargo install k4000
cd [your project]
claude mcp add --transport stdio k4000-feature -- ~/.cargo/bin/k4000-feature-mcp
claude mcp add --transport stdio k4000-review  -- ~/.cargo/bin/k4000-review-mcp
```


## Architecture

K4000 consists of two MCP servers:

- **Feature Analyzer MCP** - Manages feature documents, questions, and status tracking
- **Code Review MCP** - Orchestrates code review with specialized perspectives

Both servers communicate via the [Model Context Protocol](https://modelcontextprotocol.io/), allowing any MCP-compatible client (like Claude Code) to use them.

## Quick Start

### Build

```bash
cargo build --release
```

### Configure MCP Client

Add to your MCP configuration:

```json
{
  "k4000-feature": {
    "command": "./target/release/k4000-feature-mcp",
    "env": { "K4000_DATA_DIR": "./data" }
  },
  "k4000-review": {
    "command": "./target/release/k4000-review-mcp",
    "env": { "K4000_DATA_DIR": "./data" }
  }
}
```

### Usage

See [CLAUDE.md](CLAUDE.md) for detailed workflow instructions and tool documentation.

## Project Structure

```
k4000/
├── Cargo.toml                 # Workspace configuration
├── CLAUDE.md                  # Detailed usage documentation
├── crates/
│   ├── k4000-core/           # Shared types and storage
│   │   └── src/
│   │       ├── lib.rs
│   │       ├── error.rs      # Error types
│   │       ├── storage.rs    # File-based state management
│   │       └── types/
│   │           ├── feature.rs # Feature types
│   │           └── review.rs  # Review types
│   ├── k4000-feature-mcp/    # Feature Analyzer MCP server
│   │   └── src/
│   │       ├── main.rs
│   │       └── server.rs
│   └── k4000-review-mcp/     # Code Review MCP server
│       └── src/
│           ├── main.rs
│           └── server.rs
└── data/                      # Runtime data (gitignored)
```

## Review Perspectives

The Code Review MCP analyzes code from 5 perspectives:

| Perspective | Focus |
|-------------|-------|
| Bugs | Logic errors, edge cases, null handling |
| Best Practices | Coding standards, patterns, maintainability |
| Security | Vulnerabilities, injection, authentication |
| Performance | Efficiency, memory, algorithmic complexity |
| Simplification | Code that could be cleaner or simpler |

## Feature Status Workflow

```
draft → analyzing → awaiting_answers → ready → implementing → reviewing → done
```

## License

MIT
