diff-review-system


Namediff-review-system JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryDiff Review System - AI-powered code reviewer based on Claude Code
upload_time2025-08-11 12:17:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT
keywords ai claude code-review diff gitlab
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DRS - Diff Review System ๐Ÿง ๐Ÿ”

> AI-powered code review with intelligent context detection and GitLab integration โœจ

[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![uv](https://img.shields.io/badge/built%20with-uv-green)](https://github.com/astral-sh/uv)
[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)

## What is DRS?

DRS is a modern code review system that leverages the Claude Code SDK to provide intelligent, context-aware code analysis. Unlike traditional static analysis tools, DRS understands your development workflow and adapts its review strategy based on whether you're working locally, reviewing merge requests, or running in CI/CD environments.

## Key Features

### Smart Context Detection ๐Ÿ”Ž
- **Local Development**: Reviews `staged`, `unstaged`, and `untracked` files
- **MR Review (Local)**: Uses GitLab CLI for comprehensive MR analysis
- **GitLab CI/CD**: Proper branch diffing with full MR scope

### Multiple Output Formats ๐Ÿงพ
- **Human-readable text** for local development and debugging
- **GitLab Code Quality JSON** for seamless CI/CD integration
- **Auto-detection** based on environment

### AI-Powered Analysis ๐Ÿค–
- Uses Claude Code SDK for deep semantic understanding
- Specialized code-reviewer subagent for consistent quality
- Context-aware git command generation

### Clean Architecture ๐Ÿงฑ
- Modular design with separation of concerns
- Easy to test, maintain, and extend
- Type-checked with `mypy`, formatted with `ruff`

## Quick Start

### Prerequisites ๐Ÿ“ฆ
- Python 3.12+
- [uv](https://github.com/astral-sh/uv) package manager
- [GitLab CLI](https://gitlab.com/gitlab-org/cli) (`glab`) (for MR reviews)

### Installation โšก

```bash
# From PyPI (recommended)
pip install diff-review-system

# Use the CLI
drs --help
# or
diff-review-system --help

# From source (dev)
git clone <repository-url>
cd drs
uv sync
uv run drs --help
```

## Usage ๐Ÿš€

### Local Development Review
```bash
# Review current changes (staged + unstaged + untracked)
uv run drs --local

# Save review to file
uv run drs --local -o review.md
```

### GitLab Merge Request Review
```bash
# Review specific MR locally
uv run drs --mr-id 123

# Generate GitLab-compatible JSON
uv run drs --mr-id 456 --format gitlab-json -o code-quality.json
```

### CI/CD Integration
```yaml
# .gitlab-ci.yml
code_quality:
  stage: test
  script:
    - uv sync
    - uv run drs --format gitlab-json -o gl-code-quality-report.json
  artifacts:
    reports:
      codequality: gl-code-quality-report.json
```

## Architecture ๐Ÿ—๏ธ

```
drs/
    main.py               # CLI entry point (~45 lines)
    context.py            # Context detection (~130 lines)
    claude_integration.py # Claude SDK integration (~110 lines)
    reviewer.py           # Review orchestration (~65 lines)

.claude/
    agents/
        code-reviewer.md # Specialized review subagent
```

### How It Works ๐Ÿ› ๏ธ

1. **Context Detection** โ€“ Determines review environment
2. **Git Command Generation** โ€“ Creates appropriate git commands
3. **Subagent Invocation** โ€“ Calls the specialized code-reviewer
4. **Output Processing** โ€“ Formats results for the target environment

## Output Examples ๐Ÿงช

### Text Format (Local Development)
```markdown
## Code Review Summary
Overall assessment: Good refactoring with some minor issues

## Issues Found

### MAJOR - Missing Type Annotations
**File:** `drs/main.py` (line 42)
**Category:** maintainability
**Description:** Function lacks type hints
**Recommendation:** Add type annotations for better IDE support
```

### GitLab JSON Format (CI/CD)
```json
[
  {
    "description": "Missing type annotations. Add type hints for better IDE support.",
    "check_name": "maintainability",
    "fingerprint": "a1b2c3d4e5f6",
    "severity": "major",
    "location": {
      "path": "drs/main.py",
      "lines": { "begin": 42 }
    }
  }
]
```

## Development ๐Ÿ‘ฉโ€๐Ÿ’ป

### Setup Development Environment ๐Ÿงฐ
```bash
# Install with dev dependencies
uv sync --extra dev

# Run tests
uv run ruff check
uv run mypy drs/

# Format code
uv run ruff check --fix
```

### Project Commands ๐Ÿƒ
```bash
# CLI help
uv run drs --help

# Test different contexts
uv run drs --local --format text
uv run drs --mr-id 123 --format gitlab-json

# Context testing
CI=true CI_PIPELINE_SOURCE=merge_request_event \
  CI_MERGE_REQUEST_ID=123 \
  CI_MERGE_REQUEST_TARGET_BRANCH_NAME=main \
  uv run drs --format gitlab-json
```

## Key Advantages ๐ŸŒŸ

### Over Traditional SAST Tools ๐Ÿ†š
- **Context Awareness**: Understands your workflow
- **Semantic Analysis**: Goes beyond pattern matching
- **No (or fewer) False Positives**: AI-powered relevance filtering

### Over Manual Code Review ๐Ÿ™‹
- **Consistency**: Same quality standards every time
- **Speed**: Instant feedback on changes
- **Integration**: Seamless CI/CD workflow

### Technical Excellence ๐Ÿ› ๏ธ
- **No Redundant Operations**: Single git command execution
- **Proper MR Scope**: Reviews all commits vs target branch
- **Direct JSON Output**: No fragile regex parsing
- **Modular Architecture**: Easy to maintain and extend

## Documentation ๐Ÿ“š

- **[CLAUDE guide](CLAUDE.md)**: Comprehensive project documentation
- **[Claude agents directory](/.claude/agents/)**: Subagent configurations
- **Code Comments**: Inline documentation throughout

## Contributing ๐Ÿค

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests: `uv run ruff check && uv run mypy drs/`
5. Submit a pull request

## License ๐Ÿ“„

[MIT License](LICENSE)

โ€” Happy reviewing! ๐ŸŽ‰

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "diff-review-system",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "ai, claude, code-review, diff, gitlab",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d7/a5/57ab6f73f317dc663769b79a0e90526cd971c5010114292710b263bbc0dc/diff_review_system-0.3.0.tar.gz",
    "platform": null,
    "description": "# DRS - Diff Review System \ud83e\udde0\ud83d\udd0d\n\n> AI-powered code review with intelligent context detection and GitLab integration \u2728\n\n[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)\n[![uv](https://img.shields.io/badge/built%20with-uv-green)](https://github.com/astral-sh/uv)\n[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)\n\n## What is DRS?\n\nDRS is a modern code review system that leverages the Claude Code SDK to provide intelligent, context-aware code analysis. Unlike traditional static analysis tools, DRS understands your development workflow and adapts its review strategy based on whether you're working locally, reviewing merge requests, or running in CI/CD environments.\n\n## Key Features\n\n### Smart Context Detection \ud83d\udd0e\n- **Local Development**: Reviews `staged`, `unstaged`, and `untracked` files\n- **MR Review (Local)**: Uses GitLab CLI for comprehensive MR analysis\n- **GitLab CI/CD**: Proper branch diffing with full MR scope\n\n### Multiple Output Formats \ud83e\uddfe\n- **Human-readable text** for local development and debugging\n- **GitLab Code Quality JSON** for seamless CI/CD integration\n- **Auto-detection** based on environment\n\n### AI-Powered Analysis \ud83e\udd16\n- Uses Claude Code SDK for deep semantic understanding\n- Specialized code-reviewer subagent for consistent quality\n- Context-aware git command generation\n\n### Clean Architecture \ud83e\uddf1\n- Modular design with separation of concerns\n- Easy to test, maintain, and extend\n- Type-checked with `mypy`, formatted with `ruff`\n\n## Quick Start\n\n### Prerequisites \ud83d\udce6\n- Python 3.12+\n- [uv](https://github.com/astral-sh/uv) package manager\n- [GitLab CLI](https://gitlab.com/gitlab-org/cli) (`glab`) (for MR reviews)\n\n### Installation \u26a1\n\n```bash\n# From PyPI (recommended)\npip install diff-review-system\n\n# Use the CLI\ndrs --help\n# or\ndiff-review-system --help\n\n# From source (dev)\ngit clone <repository-url>\ncd drs\nuv sync\nuv run drs --help\n```\n\n## Usage \ud83d\ude80\n\n### Local Development Review\n```bash\n# Review current changes (staged + unstaged + untracked)\nuv run drs --local\n\n# Save review to file\nuv run drs --local -o review.md\n```\n\n### GitLab Merge Request Review\n```bash\n# Review specific MR locally\nuv run drs --mr-id 123\n\n# Generate GitLab-compatible JSON\nuv run drs --mr-id 456 --format gitlab-json -o code-quality.json\n```\n\n### CI/CD Integration\n```yaml\n# .gitlab-ci.yml\ncode_quality:\n  stage: test\n  script:\n    - uv sync\n    - uv run drs --format gitlab-json -o gl-code-quality-report.json\n  artifacts:\n    reports:\n      codequality: gl-code-quality-report.json\n```\n\n## Architecture \ud83c\udfd7\ufe0f\n\n```\ndrs/\n    main.py               # CLI entry point (~45 lines)\n    context.py            # Context detection (~130 lines)\n    claude_integration.py # Claude SDK integration (~110 lines)\n    reviewer.py           # Review orchestration (~65 lines)\n\n.claude/\n    agents/\n        code-reviewer.md # Specialized review subagent\n```\n\n### How It Works \ud83d\udee0\ufe0f\n\n1. **Context Detection** \u2013 Determines review environment\n2. **Git Command Generation** \u2013 Creates appropriate git commands\n3. **Subagent Invocation** \u2013 Calls the specialized code-reviewer\n4. **Output Processing** \u2013 Formats results for the target environment\n\n## Output Examples \ud83e\uddea\n\n### Text Format (Local Development)\n```markdown\n## Code Review Summary\nOverall assessment: Good refactoring with some minor issues\n\n## Issues Found\n\n### MAJOR - Missing Type Annotations\n**File:** `drs/main.py` (line 42)\n**Category:** maintainability\n**Description:** Function lacks type hints\n**Recommendation:** Add type annotations for better IDE support\n```\n\n### GitLab JSON Format (CI/CD)\n```json\n[\n  {\n    \"description\": \"Missing type annotations. Add type hints for better IDE support.\",\n    \"check_name\": \"maintainability\",\n    \"fingerprint\": \"a1b2c3d4e5f6\",\n    \"severity\": \"major\",\n    \"location\": {\n      \"path\": \"drs/main.py\",\n      \"lines\": { \"begin\": 42 }\n    }\n  }\n]\n```\n\n## Development \ud83d\udc69\u200d\ud83d\udcbb\n\n### Setup Development Environment \ud83e\uddf0\n```bash\n# Install with dev dependencies\nuv sync --extra dev\n\n# Run tests\nuv run ruff check\nuv run mypy drs/\n\n# Format code\nuv run ruff check --fix\n```\n\n### Project Commands \ud83c\udfc3\n```bash\n# CLI help\nuv run drs --help\n\n# Test different contexts\nuv run drs --local --format text\nuv run drs --mr-id 123 --format gitlab-json\n\n# Context testing\nCI=true CI_PIPELINE_SOURCE=merge_request_event \\\n  CI_MERGE_REQUEST_ID=123 \\\n  CI_MERGE_REQUEST_TARGET_BRANCH_NAME=main \\\n  uv run drs --format gitlab-json\n```\n\n## Key Advantages \ud83c\udf1f\n\n### Over Traditional SAST Tools \ud83c\udd9a\n- **Context Awareness**: Understands your workflow\n- **Semantic Analysis**: Goes beyond pattern matching\n- **No (or fewer) False Positives**: AI-powered relevance filtering\n\n### Over Manual Code Review \ud83d\ude4b\n- **Consistency**: Same quality standards every time\n- **Speed**: Instant feedback on changes\n- **Integration**: Seamless CI/CD workflow\n\n### Technical Excellence \ud83d\udee0\ufe0f\n- **No Redundant Operations**: Single git command execution\n- **Proper MR Scope**: Reviews all commits vs target branch\n- **Direct JSON Output**: No fragile regex parsing\n- **Modular Architecture**: Easy to maintain and extend\n\n## Documentation \ud83d\udcda\n\n- **[CLAUDE guide](CLAUDE.md)**: Comprehensive project documentation\n- **[Claude agents directory](/.claude/agents/)**: Subagent configurations\n- **Code Comments**: Inline documentation throughout\n\n## Contributing \ud83e\udd1d\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Run tests: `uv run ruff check && uv run mypy drs/`\n5. Submit a pull request\n\n## License \ud83d\udcc4\n\n[MIT License](LICENSE)\n\n\u2014 Happy reviewing! \ud83c\udf89\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Diff Review System - AI-powered code reviewer based on Claude Code",
    "version": "0.3.0",
    "project_urls": null,
    "split_keywords": [
        "ai",
        " claude",
        " code-review",
        " diff",
        " gitlab"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fcfb958dab8d861a07ca8a749db0f66acf8291a8192a0e7a559a39d5a5645f78",
                "md5": "91b9281ed91d260d1c77e8dfdbd571ab",
                "sha256": "72289f327f211327d212f7e855fb3ddde1d2d5a57d035e9e71810bfc137118bc"
            },
            "downloads": -1,
            "filename": "diff_review_system-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "91b9281ed91d260d1c77e8dfdbd571ab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 16550,
            "upload_time": "2025-08-11T12:17:02",
            "upload_time_iso_8601": "2025-08-11T12:17:02.019382Z",
            "url": "https://files.pythonhosted.org/packages/fc/fb/958dab8d861a07ca8a749db0f66acf8291a8192a0e7a559a39d5a5645f78/diff_review_system-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d7a557ab6f73f317dc663769b79a0e90526cd971c5010114292710b263bbc0dc",
                "md5": "76f2132262475fb60a2617e10994893c",
                "sha256": "38f89d87446760c9b7e4b20be06506aa9a8237a2113453b34fef0fa909b115f6"
            },
            "downloads": -1,
            "filename": "diff_review_system-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "76f2132262475fb60a2617e10994893c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 17811,
            "upload_time": "2025-08-11T12:17:02",
            "upload_time_iso_8601": "2025-08-11T12:17:02.972288Z",
            "url": "https://files.pythonhosted.org/packages/d7/a5/57ab6f73f317dc663769b79a0e90526cd971c5010114292710b263bbc0dc/diff_review_system-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-11 12:17:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "diff-review-system"
}
        
Elapsed time: 0.92349s