rw_git 2.0.0 copy "rw_git: ^2.0.0" to clipboard
rw_git: ^2.0.0 copied to clipboard

A Dart git wrapper and MCP server that facilitates the execution of various git commands and AI repository analysis.

Github logo

Github action dart.yml badge Code Coverage License: MIT

Empowering Dart & AI with Git #

rw_git bridges the gap between your applications, artificial intelligence, and Git repositories.

Whether you are building a Dart backend, a developer tool, or connecting an AI agent like Claude or Cursor to your codebase, rw_git provides a secure, high-performance, and deeply integrated Git experience.

Documentation

Core Git Commands #

Provides a clean, fluent API (RwGit facade) for all standard Git operations with robust, type-safe error handling.

  • init: Initializes a new Git repository.
  • clone: Clones a remote repository to a local directory.
  • checkout: Switches branches or restores working tree files.
  • branch: Lists, creates, or deletes branches.
  • status: Displays the state of the working directory and the staging area.
  • pull: Fetches from and integrates with another repository or a local branch.
  • push: Updates remote refs along with associated objects.
  • diff: Shows changes between commits, commit and working tree, etc.
  • merge: Joins two or more development histories together.
  • stash: Stashes the changes in a dirty working directory away.
  • blame: Shows what revision and author last modified each line of a file.
  • show: Shows various types of objects (commits, trees, tags).
  • fetchTags: Fetches all tags from the remote repository.
  • getCommitsBetween: Retrieves a list of commits between two tags or branches.
  • stats: Retrieves code-change statistics (insertions, deletions, files changed) between two points.

Model Context Protocol (MCP) Server #

rw_git ships with an embedded Model Context Protocol (MCP) server that allows AI agents and IDEs to interact directly with your git repositories. It communicates over standard I/O using JSON-RPC 2.0.

Available MCP Tools #

rw_git provides a comprehensive suite of tools for AI agents to analyze and manipulate your repository:

Repository Operations:

  • init_repository: Initializes a new Git repository.
  • clone_repository: Clones a remote repository.
  • clone_specific_branch: Clones a specific branch of a remote repository.
  • checkout_branch: Switches branches.
  • execute_git_command: Executes raw Git CLI commands (with safety restrictions).
  • is_git_repository: Checks if a directory is a valid Git repository.
  • fetch_tags: Retrieves all tags from the repository.

Analysis & Metrics:

  • analyze_code_quality: Analyzes recent commits to identify code smells and technical debt.
  • analyze_code_quality_with_authors: Analyzes code quality metrics along with author contributions.
  • analyze_bus_factor: Calculates the "bus factor" by analyzing file ownership and contribution concentration.
  • analyze_commit_velocity: Computes time-series commit velocity to track team productivity trends.
  • analyze_dependency_drift: Parses dependency manifests for supply chain risk analysis.
  • analyze_file_ownership: Cross-references CODEOWNERS with git blame history for ownership drift.
  • analyze_pr_diff: Analyzes PR diffs for risk signals like high churn and exposed secrets.
  • analyze_release_delta: Analyzes the changes and impact between two release tags.
  • predict_merge_conflicts: Identifies files modified on both branches to predict merge conflicts.
  • get_stats: Retrieves Git statistics like insertions and deletions.
  • get_commits_between: Lists commits between two tags or branches.
  • get_contributions_by_author: Retrieves commit counts grouped by author.
  • clone_and_get_statistics: Clones a repository and immediately retrieves its statistics.

Security & Compliance:

  • audit_compliance: Scans commit history for unsigned commits, empty messages, and unrecognized author emails.
  • detect_secrets_in_commits: Scans commit history for exposed secrets or credentials.

Code Review AI Agents:

  • evaluate_comment_llm_generation: Detects if code comments were likely generated by an LLM.
  • evaluate_comment_necessity: Evaluates if comments are redundant or if the code could be self-documenting.
  • evaluate_comment_quality: Analyzes the quality and usefulness of newly added comments.

Connecting MCP with Agents #

To use the MCP server, you can choose from several installation methods depending on your environment.

NPM / NPX (Recommended for Claude/Cursor/AGY) The easiest way is to run the server via npx (requires Node.js):

npx -y @gbrandtio/rw-git-mcp

Homebrew (macOS / Linux)

brew tap gbrandtio/rw-git
brew install rw-git-mcp

Dart SDK (For Dart/Flutter developers)

dart pub global activate rw_git

Pre-compiled Binaries You can also download standalone native executables for Windows, macOS (Intel/Apple Silicon), and Linux from the GitHub Releases page.

Claude Desktop

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "rw_git": {
      "command": "npx",
      "args": ["-y", "@gbrandtio/rw-git-mcp"]
    }
  }
}

Cursor

In Cursor's mcp.json or .cursor/mcp.json:

{
  "mcpServers": {
    "rw_git": {
      "command": "npx",
      "args": ["-y", "@gbrandtio/rw-git-mcp"]
    }
  }
}

Antigravity (AGY CLI / Web IDE)

Add this to your MCP configuration block:

{
  "mcpServers": {
    "rw_git": {
      "command": "npx",
      "args": ["-y", "@gbrandtio/rw-git-mcp"]
    }
  }
}

(Note: If you installed via Homebrew, Dart global activate, or downloaded the binaries, replace npx and its args with the absolute path to the executable, e.g., ["/usr/local/bin/rw-git-mcp"] or ["/path/to/rw_git_mcp"]).


Getting started #

Add the package to your pubspec.yaml:

dependencies:
  rw_git: ^2.0.0

Quick Start #

Initialize the facade and start executing Git operations seamlessly:

import 'package:rw_git/rw_git.dart';

void main() async {
  // 1. Initialize the wrapper
  RwGit rwGit = RwGit();

  // 2. Clone a repository
  String localDir = "./my-project";
  await rwGit.clone(localDir, "https://github.com/google/flutter");

  // 3. Retrieve code-change statistics
  final stats = await rwGit.stats(localDir, "old-tag", "new-tag");
  print('Files Changed: ${stats.numberOfChangedFiles}');
}

For comprehensive API details, please check our official documentation.

Additional information #

Please file any issues on the github issue tracker.

3
likes
0
points
831
downloads

Publisher

verified publisherpub.gbrandtio.dev

Weekly Downloads

A Dart git wrapper and MCP server that facilitates the execution of various git commands and AI repository analysis.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

libgit2dart, path

More

Packages that depend on rw_git