npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spahce/acr

v0.1.1

Published

AI-powered code review CLI tool using Anthropic Claude API

Downloads

391

Readme

acr - AI Code Review

AI 驱动的代码审查与提交工具。通过 AI 自动生成规范的 commit message,同时对代码变更进行审查,发现潜在问题。

特性

  • 智能提交 — AI 自动生成 Conventional Commits 格式的 commit message
  • 代码审查 — AI 分析代码变更,标注问题(严重/警告/建议)和亮点
  • 交互式操作 — 审查完成后通过方向键选择提交、推送或取消
  • 流式输出 — 实时显示 AI 审查过程
  • 上下文感知 — 自动读取相关源文件,提供更准确的审查
  • 多语言输出 — 支持中文、英文、日文等多种输出语言
  • 灵活配置 — 支持交互式设置、配置文件、环境变量三种方式
  • Git Hook — 可选的自动化审查,commit 时自动触发

安装

npm install -g @spahce/acr

要求 Node.js >= 18。

快速开始

# 1. 暂存你的代码变更
git add .

# 2. 运行 acr
acr

首次运行会提示输入 AI 服务配置(API 地址、密钥、模型),配置会保存到 ~/.acr/config.json

之后 acr 会自动完成以下流程:

  1. 分析暂存的代码变更
  2. AI 生成 commit message 和代码审查
  3. 展示结果,等待你选择操作(提交并推送 / 仅提交 / 取消)

配置

交互式配置(推荐)

# 首次运行时自动触发,或手动运行:
acr config

按提示输入 API 地址、密钥和模型名称,配置保存到 ~/.acr/config.json

配置文件

直接编辑 ~/.acr/config.json

{
  "baseUrl": "https://api.anthropic.com",
  "authToken": "sk-ant-...",
  "model": "claude-sonnet-4-20250514"
}

环境变量

export ANTHROPIC_BASE_URL=https://api.anthropic.com
export ANTHROPIC_AUTH_TOKEN=sk-ant-...
export ANTHROPIC_MODEL=claude-sonnet-4-20250514    # 可选,有默认值

优先级: 环境变量 > 配置文件 > 交互式设置。

使用方式

默认模式:提交 + 审查

# 暂存变更后直接运行
acr

AI 会在一次调用中同时生成 commit message 和代码审查。审查结果展示后,通过方向键选择:

  • 提交并推送 — 执行 git commit + git push(有远程仓库时显示)
  • 仅提交 — 只执行 git commit
  • 取消 — 放弃操作

审查模式:仅查看审查结果

# 审查已暂存的变更
acr --staged

# 审查指定的 commit
acr --commit abc1234

# 审查两个引用之间的差异
acr --diff main...HEAD

# 限定审查特定文件
acr --staged --file src/index.ts

# 使用英文输出
acr --staged --lang en

CLI 参考

acr [选项] [命令]

选项:
  --staged              仅审查已暂存的变更(不提交)
  --commit <sha>        审查指定的 commit
  --diff <range>        审查两个引用之间的差异(如 main...HEAD)
  --file <path...>      限定审查指定文件
  --context <n>         diff 上下文行数(默认: 3)
  --lang <language>     输出语言(默认: zh)
  --no-stream           禁用流式输出
  -V, --version         显示版本号
  -h, --help            显示帮助信息

命令:
  config                配置 AI 服务参数
  hook install          安装 git hook(支持 --global --force)
  hook uninstall        卸载 git hook(支持 --global)

Git Hook

安装 hook 后,每次 git commit 时自动执行代码审查:

# 在当前仓库安装
acr hook install

# 全局安装(对所有仓库生效)
acr hook install --global

# 卸载
acr hook uninstall
acr hook uninstall --global

审查输出格式

审查结果包含三个部分:

  • 概要 — 变更内容的简要总结
  • 问题 — 发现的问题,按严重程度标注:
    • 🔴 严重 — Bug、安全漏洞、数据丢失风险
    • 🟡 警告 — 潜在问题、性能隐患、不良实践
    • 🔵 建议 — 改进建议、风格优化
  • 亮点 — 代码中做得好的地方:
    • 🟢 优秀

许可证

MIT