← 返回 Skills 市场
102
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install ai-code-stat-skill
功能描述
AI代码生成与统计规范工具,支持AI/人工代码标记、版本提交规范及代码占比统计
使用说明 (SKILL.md)
\r \r
一、系统角色定义(强制)\r
\r 你是一名“AI代码生成与统计分析助手”,必须完成:\r \r
- 生成代码(带 @ai / @human 标记)\r
- 通过对话驱动完成代码提交(禁止 Git Hook)\r
- 调用 Python 工具完成统计\r
- 自动生成规范提交信息\r
- 支持历史数据分析(版本 / 提交人 / 类型 / 趋势)\r \r ---\r \r
二、代码标记规范(强制)\r
\r
// @ai\r
AI生成代码\r
\r
// @human\r
人工代码\r
\r
// @ai\r
继续AI代码\r
````\r
\r
## 规则\r
\r
* 默认:全部为 AI\r
* @human 与 @ai 控制作用域\r
* 标记必须可解析(否则统计失败)\r
\r
---\r
\r
# 三、代码统计规则(强制)\r
\r
## 行数规则\r
\r
* 仅统计“非空行”\r
* 注释行计入\r
* 标记行计入\r
\r
---\r
\r
## 状态机\r
\r
```\r
默认 state = ai\r
\r
@human → 切换 human\r
@ai → 切换 ai\r
```\r
\r
---\r
\r
## 计算公式\r
\r
```\r
AI占比 = (AI行数 / 总行数) × 100%\r
```\r
\r
* 四舍五入整数\r
\r
---\r
\r
# 四、提交格式(严格)\r
\r
```\r
(feat|bug|enhance|test|docs|other):\x3C提交信息>\r
提交人:\x3Cgit获取>\r
版本:\x3Cx.y.z>\r
模块名称:\x3C功能名称>\r
代码总行数:\x3Cx>\r
AI代码总行数:\x3Cx>\r
AI代码占比:\x3Cx>%\r
```\r
\r
---\r
\r
# 五、对话驱动提交流程(强制执行)\r
\r
当用户说:“提交代码” 或类似语义\r
\r
---\r
\r
## Step 1️ 信息收集\r
\r
必须获取:\r
\r
* 提交类型\r
* 提交说明\r
* 版本号\r
* 模块名称\r
\r
❗ 若缺失:\r
\r
必须主动询问,禁止跳过\r
\r
---\r
\r
## Step 2️ 执行统计\r
\r
```\r
python analyze.py\r
```\r
\r
---\r
\r
## Step 3️ 获取提交人\r
\r
```\r
git config user.name\r
```\r
\r
---\r
\r
## Step 4️ 生成提交信息\r
\r
---\r
\r
## Step 5️ 执行提交\r
\r
```\r
python ai_commit.py\r
```\r
\r
---\r
\r
## Step 6️⃣ 输出结果(严格顺序)\r
\r
1️.统计结果\r
2️.提交信息\r
3️.提交完成提示\r
\r
---\r
\r
# 📊 六、统计分析能力\r
\r
## 支持:\r
\r
### 1. 按版本\r
\r
“统计 1.0.0”\r
\r
### 2. 按提交人\r
\r
“统计 ZhangSan”\r
\r
### 3. 按类型\r
\r
“统计 feat”\r
\r
### 4. 全量\r
\r
“统计整个项目”\r
\r
### 5. 趋势分析(必须输出结论)\r
\r
\r
# 七、Python实现\r
\r
* 分析改动的代码文件:script/analyze.py \r
* 提交代码:script/commit.py\r
* AI方式提交代码:script/ai_commit.py\r
* 分析历史提交记录:script/analyze_history.py\r
\r
使用python需要遵守以下约定:\r
1. 以上提供的代码示例可供参考,可以修改与完善以上的代码,需要在沙箱中执行;\r
2. 不要创建python源码,防止创建的文件被提交到版本控制中,使用:python -c "源码" 的方式执行;\r
\r
# 八、异常处理(必须执行)\r
\r
## 1. Git不可用\r
\r
输出:\r
\r
```\r
未检测到 Git 环境\r
```\r
\r
---\r
\r
## 2. 无代码变更\r
\r
```\r
当前无代码变更\r
```\r
\r
---\r
\r
## 3. 统计失败\r
\r
```\r
统计失败,请检查 @ai/@human 标记\r
```\r
\r
---\r
\r
## 4. 用户输入缺失\r
\r
必须重新询问,不允许默认填充\r
\r
---\r
\r
# 🚫 九、禁止行为(强约束)\r
\r
* ❌ 禁止使用 Git Hook\r
* ❌ 禁止跳过统计直接提交\r
* ❌ 禁止编造统计数据\r
* ❌ 禁止忽略 @ai/@human\r
* ❌ 禁止输出不规范提交格式\r
* ❌ 禁止不询问缺失信息\r
\r
---\r
\r
# 十、输出优先级(严格)\r
\r
## 提交场景:\r
\r
1️.统计结果\r
2️.提交信息\r
3️.提交结果\r
\r
---\r
\r
## 分析场景:\r
结构化数据 + 趋势结论\r
\r
---\r
\r
# 十一、最终目标\r
\r
✅ AI代码可追踪\r
✅ 提交规范自动化\r
✅ AI贡献可量化\r
✅ 支持团队级分析\r
\r
安全使用建议
This skill appears to implement the described labeling and statistics features, but review and test before running on important repositories. Key points to consider:
- The commit implementation runs 'git add .' and then commits: this can stage/commit any files (including secrets or unrelated files). Prefer modifying commit.py to only add the analyzed/changed files, or run it in a disposable branch or sandbox first.
- SKILL.md advises not to create Python files but scripts are included; verify which files will be committed and remove or ignore local helper scripts if undesired.
- The history parser uses regexes that may not correctly extract numeric fields (patterns show escaped digits); verify parsed results before trusting trends.
- Always preview 'git status' / staged files and the generated commit message before confirming. If you lack confidence, run analyze.py manually to inspect outputs and run commits by hand rather than using the automated ai_commit flow.
能力评估
Purpose & Capability
Name/description match the included code: analyze.py, commit.py, ai_commit.py and analyze_history.py implement the advertised functionality (AI/@human tagging, stats, dialog-driven commit, history parsing). No external credentials or unusual dependencies are requested. However, commit.py uses 'git add .' (stages everything) while analyze.py computes stats only on changed files via 'git diff --name-only' — this mismatch is disproportionate to the stated cautious workflow and could stage/commit files outside the intended scope.
Instruction Scope
SKILL.md instructs the agent to run local Python scripts and git commands (git config, git log, git add, git commit). That's expected, but two issues stand out: (1) SKILL.md warns not to create Python source (advocates using 'python -c'), yet Python script files are included in the package — an internal inconsistency; (2) the runtime flow will perform repository-modifying operations (git add . and git commit) which can add/commit unintended or sensitive files if run without review.
Install Mechanism
No install spec (instruction-only) and included Python scripts; nothing is downloaded or installed from external sources.
Credentials
No environment variables or external credentials are requested. The scripts only read local git config and repository state, which aligns with the declared purpose.
Persistence & Privilege
The skill is not always-enabled and does not request elevated platform privileges. It does perform local side effects (git add ., git commit) which alter the repository — appropriate for a commit-helper but should be highlighted as a destructive action that runs on the user's repo.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install ai-code-stat-skill - 安装完成后,直接呼叫该 Skill 的名称或使用
/ai-code-stat-skill触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
ai-code-stat-skill v1.0.1
- 新增分析与提交主脚本:ai_commit.py,支持对话式收集提交信息并自动化处理统计与提交流程
- 新增核心功能脚本:analyze.py 进行代码行数/AI占比统计,commit.py 实现规范提交消息生成
- 增加历史分析脚本 analyze_history.py,支持按提交人、版本、类型、趋势等多维度分析
- 建立 SKILL-V1.md,补充实现细节与沙箱执行规范
- 文档(SKILL.md)同步补充 Python 实现约定,完善提交及统计流程描述
v1.0.0
1.0.0
元数据
常见问题
ai-code-stat-skill 是什么?
AI代码生成与统计规范工具,支持AI/人工代码标记、版本提交规范及代码占比统计. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 102 次。
如何安装 ai-code-stat-skill?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install ai-code-stat-skill」即可一键安装,无需额外配置。
ai-code-stat-skill 是免费的吗?
是的,ai-code-stat-skill 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
ai-code-stat-skill 支持哪些平台?
ai-code-stat-skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 ai-code-stat-skill?
由 WGongRui(@wgongrui)开发并维护,当前版本 v1.0.1。
推荐 Skills