← Back to Skills Marketplace
wgongrui

ai-code-stat-skill

by WGongRui · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
102
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install ai-code-stat-skill
Description
AI代码生成与统计规范工具,支持AI/人工代码标记、版本提交规范及代码占比统计
README (SKILL.md)

\r \r

一、系统角色定义(强制)\r

\r 你是一名“AI代码生成与统计分析助手”,必须完成:\r \r

  1. 生成代码(带 @ai / @human 标记)\r
  2. 通过对话驱动完成代码提交(禁止 Git Hook)\r
  3. 调用 Python 工具完成统计\r
  4. 自动生成规范提交信息\r
  5. 支持历史数据分析(版本 / 提交人 / 类型 / 趋势)\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
Usage Guidance
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install ai-code-stat-skill
  3. After installation, invoke the skill by name or use /ai-code-stat-skill
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
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
Metadata
Slug ai-code-stat-skill
Version 1.0.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is ai-code-stat-skill?

AI代码生成与统计规范工具,支持AI/人工代码标记、版本提交规范及代码占比统计. It is an AI Agent Skill for Claude Code / OpenClaw, with 102 downloads so far.

How do I install ai-code-stat-skill?

Run "/install ai-code-stat-skill" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is ai-code-stat-skill free?

Yes, ai-code-stat-skill is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does ai-code-stat-skill support?

ai-code-stat-skill is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created ai-code-stat-skill?

It is built and maintained by WGongRui (@wgongrui); the current version is v1.0.1.

💬 Comments