The project is in a healthy, maintained state
NitPicker is a command-line tool that uses AI to review your staged Git changes and provide constructive feedback
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 5.0
~> 13.0
~> 3.0

Runtime

~> 2.0
 Project Readme

NitPicker

NitPicker is a command-line tool that provides AI-powered code reviews for your Git changes. It analyzes your staged changes by default, but can also review any diff piped to it. It offers scathing and mercilessly critical feedback to help improve code quality, security, performance, and maintainability by making you feel like an idiot.

Features

  • AI-powered code review of staged Git changes or any piped diff
  • Comprehensive analysis covering code quality, security, performance, and best practices
  • Customizable AI prompts for tailored review feedback
  • Support for repository-specific prompts
  • Choose any AI model (OpenAI GPT-4.1-mini by default)
  • Easy integration into your Git workflow

Installation

Requirements

  • Ruby 2.6 or higher
  • Git

Option 1: Install as a Gem (Recommended)

gem install nitpicker-code-review

This automatically adds NitPicker to your PATH.

Option 2: Build and Install from Source

Clone this repository:

git clone https://github.com/jubishop/NitPicker.git
cd NitPicker

Build and install the gem:

gem build gemspec/nitpicker.gemspec
gem install nitpicker-code-review-*.gem

Option 3: Manual Installation

Clone this repository:

git clone https://github.com/jubishop/NitPicker.git
cd NitPicker

Make the script executable:

chmod +x bin/nitpicker

Create a symbolic link to make NitPicker available globally:

ln -s "$(pwd)/bin/nitpicker" /usr/local/bin/nitpicker

Configuration

API Key Setup

NitPicker requires an OpenRouter API key to generate code reviews. You need to set this as an environment variable:

export OPENROUTER_API_KEY="your_openrouter_api_key"

You can get an API key from OpenRouter.

Optionally, you can specify a different model by setting:

export GIT_REVIEW_MODEL="openai/gpt-4o"

The default model is openai/gpt-4.1-mini if not specified.

Prompt Configuration

NitPicker supports two levels of prompt configuration:

  • Global Prompt (Default): Stored in ~/.config/nitpicker/prompt. This is used for all repositories unless overridden.
  • Repository-Specific Prompt: Create a .nitpicker_prompt file in the root of your Git repository to customize the prompt for that specific project.

When you run NitPicker, it will:

  • First look for a .nitpicker_prompt file in the root of the current Git repository
  • If not found, fall back to the global prompt at ~/.config/nitpicker/prompt

When you run NitPicker for the first time, if there's no global prompt file in the config directory, it will copy config/prompt to the config directory automatically.

The special string {{DIFF}} in your prompt will be replaced with the current git diff of staged changes.

Usage

Review Staged Changes (Default)

Navigate to your Git repository, stage your changes, and run:

nitpicker [options]

Review Any Diff via Pipe

You can pipe any diff into nitpicker for review:

git show | nitpicker              # Review a specific commit
git diff HEAD~1 | nitpicker       # Review changes from previous commit
git diff main..feature | nitpicker # Review differences between branches

Options:

  • --version: Show version information
  • -h, --help: Show help message

Examples

Review Staged Changes

# Stage some changes first
git add .

# Get AI code review of staged changes
nitpicker

Review Specific Commits or Diffs

# Review the last commit
git show | nitpicker

# Review changes from 2 commits ago
git show HEAD~2 | nitpicker

# Review uncommitted changes (both staged and unstaged)
git diff HEAD | nitpicker

# Review differences between branches
git diff main..feature-branch | nitpicker

# Review a range of commits
git diff HEAD~3..HEAD | nitpicker

Example output:

## Code Review Summary

**Overall Assessment:** The changes look good with a few minor suggestions for improvement.

### Positive Aspects:
- Clean, readable code structure
- Proper error handling implemented
- Good variable naming conventions

### Suggestions for Improvement:

**Security:**
- Consider validating user input on line 45 to prevent potential injection attacks

**Performance:**
- The database query on line 23 could be optimized by adding an index on the `user_id` column

**Best Practices:**
- Consider extracting the validation logic into a separate method for better reusability

License

MIT

Development

Project Structure

NitPicker follows a specific project structure where all gemspec files and built gem files (.gem) are placed in the gemspec/ folder rather than the root directory. This keeps the root directory clean and organized.

Rake Tasks

NitPicker provides several rake tasks to streamline development:

# Run the test suite
rake test

# Build the gem and place it in the gemspec/ folder
rake build

# Build, install and test the gem
rake install

# Build and push the gem to RubyGems
rake push

The default task is rake test.

Testing

NitPicker uses Minitest for testing. To run the tests:

bundle install
rake test

The test suite includes:

  • Unit tests for the CLI functionality
  • Tests for version consistency
  • Mock tests for API interactions (using WebMock)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

Author

Justin Bishop (jubishop)