Token导航 LogoToken导航

Agent Skill · 研究检索

oh-precommit-codecheck(哦预提交代码检查)

oh-precommit-codecheck 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

oh-precommit-codecheck 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为执行命令;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 68,015。

总安装 238周安装 10GitHub Stars 18下载 83核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:oh-precommit-codecheck(哦预提交代码检查)
来源仓库:https://github.com/openharmonyinsight/openharmony-skills
仓库路径:skills/oh-precommit-codecheck
安装命令:
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill oh-precommit-codecheck
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill oh-precommit-codecheck

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于查找、检索和筛选相关信息。适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词或任务场景快速定位候选结果。可结合来源仓库和原始 README 核验具体用法。安装前建议确认权限范围、维护状态及是否触发联网或文件读写。

oh-precommit-codecheck 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/oh-precommit-codecheck

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要执行命令,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

oh-precommit-codecheck 怎么安装?

在终端执行 npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill oh-precomm…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

oh-precommit-codecheck 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

oh-precommit-codecheck 需要什么权限?

权限级别是执行命令。安装流程涉及命令执行,可能通过 npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill oh-precommit-codecheck 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

oh-precommit-codecheck 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

oh-precommit-codecheck 用的人多吗?

公开数据是累计安装 238 次,近一周安装 10 次,下载 83 次,GitHub 18 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

oh-precommit-codecheck 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 需要执行命令,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 不能接受 Skill 在你机器上执行命令的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
oh-precommit-codecheck

哦预提交代码检查 · 本页

23818执行命令未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

OH Precommit Codecheck

Run local code quality checks. Includes gate CI checks and additional local-only checks.

Gate CI checks (same as OpenHarmony gate):

  • Copyright: Header presence, year correctness, comment style (/** for C/C++)
  • C/C++ format: clang-format (clang-format-14 preferred, fallback to clang-format)
  • C/C++ quality: CodeArts Check (codecheck-ide-engine + Huawei clang-tidy: clangtidy + secfinder + fixbot)

Additional local checks (NOT part of gate CI, for extra quality):

  • Python: pylint + flake8
  • Shell: shellcheck + bashate-mod-ds
  • GN: gn format --dry-run

Notes

  • First run downloads ~600MB of CodeArts tools to ~/.codecheck-tools/
  • Python/Shell linters must be pre-installed (pylint, flake8, shellcheck, bashate-mod-ds)
  • C/C++ checks without compile_commands.json may miss some context-dependent issues
  • GN format check requires gn in PATH

Current limitations

This skill covers a subset of the full OpenHarmony gate CI checks:

  • Languages: Only C/C++, Python, Shell, GN are checked. Java, JavaScript, TypeScript, ArkTS are NOT yet wired up (the CodeArts engine has rules for them locally).
  • C++ rules: ~114 of ~163 gate G.* rules are covered (~70%). Missing rules are mainly C-language variants without -CPP suffix.
  • Not covered at all: WordsTool sensitive-word checks (~200+ rules), OAT open-source compliance (~10 rules), security-specific checks (weak crypto, unsafe IPSI), code metrics (oversized functions/files/complexity, redundant/duplicate code).
  • Local pass does NOT guarantee gate pass — this is a best-effort pre-filter.

Quick Reference

InvocationModeBehavior
/oh-precommit-codecheck (standalone)Mode 1Check specified files, report results, ask before fixing
/oh-precommit-codecheck --fixMode 1Check and auto-fix up to 3 rounds
Auto-triggered by oh-pr-workflowMode 2Silent check + auto-fix, report only if defects remain
Pre-commit hookMode 2Same as auto-trigger

Determine trigger mode

Check whether $ARGUMENTS is set.

Mode 1: User-invoked ($ARGUMENTS present or /oh-precommit-codecheck called)

Parse $ARGUMENTS to determine file scope and fix mode:

/oh-precommit-codecheck              → files from: git diff --cached --name-only
/oh-precommit-codecheck <commit>     → files from: git diff-tree --no-commit-id -r <commit> --name-only
/oh-precommit-codecheck <file ...>   → the listed files directly
/oh-precommit-codecheck --fix        → same file resolution + auto-fix mode

Argument parsing rules:

  • --fix flag can appear anywhere in arguments
  • If an argument looks like a git commit (matches git rev-parse --verify <arg>), treat it as a commit
  • Otherwise treat arguments as file paths

Steps:

  1. Resolve the file list using the rules above. Filter to only existing files.
  2. Run checks by calling the check script: bash ~/.claude/skills/oh-precommit-codecheck/scripts/check.sh <file1> <file2>...
  3. Present results to the user as a concise summary table.
  4. If defects were found and --fix was NOT specified:

- Suggest: "Run /oh-precommit-codecheck --fix to auto-fix these issues."

  1. If --fix WAS specified and defects were found:

- For copyright defects: Fix the copyright header directly (add missing header, update year, change comment style). - For C/C++ defects: Read each defective file, understand the rule violation, and fix it directly using the Edit tool. - For Python defects: Read each defective file, understand the rule violation, and fix it directly using the Edit tool. - For Shell defects: Read each defective file, understand the rule violation, and fix it directly using the Edit tool. - For GN format defects: Run gn format <file> to auto-format. - After fixing, re-run the check script to verify. Repeat up to 3 rounds. - Report any remaining unfixable defects.

Mode 2: AI auto-trigger (no $ARGUMENTS, after completing code changes)

When you have just finished writing or modifying code files, automatically check them.

Steps:

  1. Collect the list of files you just modified in this conversation (from your tool call history — look at Edit/Write calls).
  2. Run checks: bash ~/.claude/skills/oh-precommit-codecheck/scripts/check.sh <modified_files...>
  3. If 0 defects: silently pass — do not mention the check to the user unless they ask.
  4. If defects found: a. Auto-fix each defect:

- For copyright: Add/update copyright header. - For C/C++ mechanical fixes (G.FMT.11-CPP braces, G.EXP.35-CPP nullptr, G.FMT.05-CPP line width): Fix directly. - For C/C++ judgment-required (G.NAM.03-CPP naming, G.FUN.01-CPP size): Do NOT auto-fix — report to user. - For Python / Shell: Fix standard rules directly, report ambiguous ones. - For GN format: Run gn format <file>. b. Re-run checks to verify fixes. c. Repeat up to 3 rounds total. d. If defects remain after 3 rounds, report the unfixable ones to the user.

Mode 2 and CLAUDE.md interaction: When triggered as pre-commit hook or by oh-pr-workflow, Mode 2 auto-fixes to streamline the commit flow. This overrides the CLAUDE.md "show report first" convention because the user has already expressed intent to commit. If invoked standalone (/oh-precommit-codecheck without commit context), default to report-only and ask before fixing.


Below: Reference sections — consult when fixing specific defect types. Skip to "Common Mistakes" if you just need guardrails.

Fix guidelines

When auto-fixing defects, match the rule to the fix below. If the rule is not listed, read the defect message and apply best judgment.

Copyright

  • no-copyright: Add the full Apache 2.0 copyright header (see CLAUDE.md for template)
  • wrong-year: Update the year range to include current year (e.g., 2025 → 2025-2026)
  • wrong-comment-style: For .cpp/.c/.h/.hpp files, change first line to /** (block comment style)

C/C++ (CodeArts)

  • G.FMT.11-CPP (braces): Add {} around single-line if/for/while/else bodies
  • G.NAM.03-CPP (naming): Fix variable/function names to match convention
  • G.EXP.35-CPP (nullptr): Replace NULL / 0 (pointer context) with nullptr
  • G.FUN.01-CPP (params): Cannot auto-fix — report to user
  • G.CNS.02-CPP (magic numbers): Extract to named constexpr constant

Python

  • C0304 (final newline): Add trailing newline
  • C0305 (trailing newline): Remove extra trailing blank lines
  • C0321 (multiple statements): Split into separate lines
  • C0410 (multiple imports): One import per line
  • C0411 (import order): Reorder to stdlib → third-party → local
  • Other pylint/flake8 rules: Read the message and fix accordingly

Shell

  • SC2086 (double-quote): Add double quotes around variable expansions
  • SC2164 (cd failure): Add || exit after cd commands
  • SC2148 (shebang): Add #!/usr/bin/env bash at top
  • Other shellcheck rules: Read the message and fix accordingly

GN

  • Run gn format <file> — fully automatic, no manual intervention needed

Common Mistakes — NEVER Do

  • NEVER run gn format on files that fail gn parse — it corrupts the file. Run gn parse first; if it fails, fix syntax manually before formatting.
  • NEVER auto-fix G.FUN.01-CPP (function too long) — requires architectural judgment. Always report to user.
  • NEVER auto-fix G.NAM.03-CPP naming without reading surrounding code — naming conventions depend on context (member variables, global variables, function params have different rules).
  • NEVER trust 0 defects from CodeArts if the engine log shows startup errors — check defects.json is non-empty AND engine exited normally.
  • NEVER assume local tool versions match gate CI — version mismatch causes false negatives. If results differ from gate, check: java -version, clang-tidy --version, pylint --version.
  • NEVER re-run the full check suite if only one checker failed — re-run only the failed checker to save time.

Error Recovery

  • CodeArts engine fails to start: Check java -version (requires 11+). Check download integrity: md5sum codecheck-ide-engine.jar. Re-run setup: bash scripts/setup_codecheck.sh --force.
  • compile_commands.json missing: C++ checks will have ~30% false negative rate. Generate with: gn gen out/default --export-compile-commands or proceed with reduced accuracy.
  • pylint/flake8 version mismatch: Gate uses specific versions. Check with pylint --version and compare with gate CI logs.

Example Output

Typical Mode 1 result:

Codecheck Results (12 defects):
| Rule | Count | File | Auto-fixable |
|------|-------|------|-------------|
| G.FMT.11-CPP | 5 | token_test.cpp | Yes |
| G.NAM.03-CPP | 3 | token_test.cpp | Yes (with context) |
| G.EXP.35-CPP | 2 | token_test.cpp | Yes |
| G.FUN.01-CPP | 1 | token_test.cpp | No — report to user |
| G.FMT.05-CPP | 1 | token_test.cpp | Yes |

发现 12 个告警,其中 11 个可自动修复。是否修复?

平台分布

Codex

34.98%
按下载量换算29

Claude

30.62%
按下载量换算25

Cursor

21.16%
按下载量换算18

Gemini CLI

10.66%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill oh-precommit-codecheck 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills