Λογότυπο Oh Precommit Codecheck

Oh Precommit Codecheck

Οργανισμός
openharmonyinsight
oh-precommit-codecheck

Run local code quality checks covering a subset of OpenHarmony gate CI (copyright, CodeArts C/C++) plus additional local checks (pylint/flake8, shellcheck/bashate, gn format). Use before committing to reduce gate failures. Triggers on: /oh-precommit-codecheck, "门禁检查", "门禁预检", "检查代码", "run codecheck", "check code quality", "lint my code", "代码检查", or after completing code implementation. WHEN to use: before git commit, before creating PR, after modifying C/C++/Python/Shell/GN files, when gate CI fails with codecheck defects, or when you want to preview what gate will flag.

Επισκόπηση

Εκδότηςopenharmonyinsight
Αποθετήριοopenharmony-skills
Όνομα δεξιότηταςoh-precommit-codecheck
Αστέρια
36
Forks
7
Συνοδευτικά αρχεία
6
Σύνδεσμοι
  • Οδηγίες σε Markdown

    Ένα αρχείο SKILL.md που το μοντέλο φορτώνει όταν χρειάζεται, ώστε να καταναλώνει token μόνο όταν ένα αίτημα είναι πράγματι σχετικό.

  • Λειτουργεί με οποιοδήποτε LLM

    Οι δεξιότητες AI είναι απλό Markdown, όχι κώδικας για συγκεκριμένο πάροχο, επομένως αυτή η δεξιότητα λειτουργεί με GPT, Claude, Gemini, Grok ή ένα τοπικό μοντέλο.

  • 6 συνοδευτικά αρχεία

    Σενάρια, πρότυπα και υλικό αναφοράς που μπορεί να διαβάζει το μοντέλο καθώς εργάζεται. Τα αρχεία είναι μόνο για ανάγνωση και δεν εκτελούνται ποτέ.

  • Ανοιχτού κώδικα

    Δημοσιεύτηκε από openharmonyinsight στο GitHub. Διαβάστε το πηγαίο περιεχόμενο πριν εγκαταστήσετε τη δεξιότητα.

Εγκατάσταση

Εγκαταστήστε τη δεξιότητα AI Oh Precommit Codecheck στο TypingMind για να τη χρησιμοποιείτε με οποιοδήποτε LLM ή προσθέστε τη σε άλλον πράκτορα AI που διαβάζει αρχεία SKILL.md.

1

Εγκατάσταση στο TypingMind

Το TypingMind εγκαθιστά μια δεξιότητα απευθείας από τον φάκελό της στο GitHub — διαβάζει το SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία σε πακέτο και αποθηκεύει το αποτέλεσμα τοπικά.

  1. Ανοίξτε την εφαρμογή και μεταβείτε στα Πρόσθετα → Δεξιότητες.
  2. Επιλέξτε «Εγκατάσταση από GitHub».
  3. Επικολλήστε το παρακάτω URL του φακέλου της δεξιότητας και επιβεβαιώστε.
    https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-precommit-codecheck
  4. Ενεργοποιήστε τη δεξιότητα σε κάθε συνομιλία όπου θέλετε να είναι διαθέσιμη.
Πρόσθετα → Δεξιότητες → Νέα δεξιότητα → Από URL του GitHub, έπειτα επικολλήστε το URL του φακέλου και πατήστε «Συνέχεια».
2

Εγκατάσταση σε άλλον πράκτορα AI

Κάθε πράκτορας AI που διαβάζει τη μορφή Agent Skills μπορεί να χρησιμοποιήσει αυτή τη δεξιότητα — αντιγράψτε τον φάκελο στον κατάλογο δεξιοτήτων του.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openharmonyinsight/openharmony-skills.git /tmp/openharmony-skills
mkdir -p .claude/skills
cp -r /tmp/openharmony-skills/skills/oh-precommit-codecheck .claude/skills/oh-precommit-codecheck
Επανεκκινήστε το Claude Code μετά την αντιγραφή, ώστε να εντοπίσει τη νέα δεξιότητα.

Χρησιμοποιήστε τη στο TypingMind

Ενεργοποιήστε τη δεξιότητα Oh Precommit Codecheck σε οποιαδήποτε συνομιλία στο TypingMind και το μοντέλο αναλαμβάνει τα υπόλοιπα. Το όνομα και η περιγραφή της περιλαμβάνονται στην προτροπή συστήματος και, μόλις προκύψει ένα σχετικό αίτημα, το μοντέλο φορτώνει μόνο του τις πλήρεις οδηγίες — δεν χρειάζεται ποτέ να την καλείτε χειροκίνητα και δεν καταναλώνει token μέχρι να χρησιμοποιηθεί πραγματικά.

Το μοντέλο φορτώνει αυτόματα τη δεξιότητα Oh Precommit Codecheck μόλις λάβει ένα σχετικό αίτημα.

Λειτουργεί με οποιοδήποτε μοντέλο AI

Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας για συγκεκριμένο πάροχο, οπότε η δεξιότητα Oh Precommit Codecheck δεν περιορίζεται στο μοντέλο για το οποίο γράφτηκε. Εγκαταστήστε τη μία φορά στο TypingMind και χρησιμοποιήστε τη με GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ή ένα τοπικό μοντέλο που εκτελείτε εσείς — πάντα με τα δικά σας κλειδιά API.

  • Φόρτωση μόνο όταν χρειάζεται

    Η προτροπή συστήματος περιλαμβάνει μόνο το όνομα και την περιγραφή. Οι οδηγίες ανακτώνται με το πρώτο σχετικό αίτημα, οπότε μια δεξιότητα που δεν χρησιμοποιείται δεν έχει κόστος.

  • Αλλάξτε μοντέλα κατά τη συνομιλία

    Επειδή η δεξιότητα αποτελείται από οδηγίες και όχι από κώδικα, η αλλαγή μοντέλου δεν επηρεάζει τη λειτουργία της — το επόμενο μοντέλο διαβάζει το ίδιο αρχείο SKILL.md.

Οδηγίες δεξιότητας

Αυτό είναι το περιεχόμενο του αρχείου 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
    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."
  5. 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
    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 个可自动修复。是否修复?

Συνοδευτικά αρχεία

Το μοντέλο τα διαβάζει όποτε χρειάζεται, όσο η δεξιότητα είναι φορτωμένη. Διατίθενται ως αρχεία για ανάγνωση και δεν εκτελούνται ποτέ.

Συχνές ερωτήσεις

Τι κάνει η δεξιότητα AI Oh Precommit Codecheck;

Run local code quality checks covering a subset of OpenHarmony gate CI (copyright, CodeArts C/C++) plus additional local checks (pylint/flake8, shellcheck/bashate, gn format). Use before committing to reduce gate failures. Triggers on: /oh-precommit-codecheck, "门禁检查", "门禁预检", "检查代码", "run codecheck", "check code quality", "lint my code", "代码检查", or after completing code implementation. WHEN to use: before git commit, before creating PR, after modifying C/C++/Python/Shell/GN files, when gate CI fails with codecheck defects, or when you want to preview what gate will flag.

Γιατί να χρησιμοποιήσετε τη δεξιότητα Oh Precommit Codecheck στο TypingMind;

Επειδή την εγκαθιστάτε μία φορά και τη χρησιμοποιείτε με οποιοδήποτε μοντέλο. Η Oh Precommit Codecheck είναι απλό Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως η ίδια δεξιότητα λειτουργεί με GPT-5, Claude, Gemini, Grok ή ένα τοπικό μοντέλο — και μπορείτε να αλλάξετε μοντέλο κατά τη διάρκεια της συνομιλίας χωρίς να διακοπεί η λειτουργία της. Το TypingMind λειτουργεί με τα δικά σας κλειδιά API, οπότε πληρώνετε απευθείας τους παρόχους αντί για συνδρομή ανά θέση χρήστη, ενώ οι δεξιότητες και οι συνομιλίες σας παραμένουν στον δικό σας χώρο αποθήκευσης.

Πώς εγκαθιστώ τη Oh Precommit Codecheck στο TypingMind;

Στο TypingMind, ανοίξτε Πρόσθετα → Δεξιότητες → Εγκατάσταση από το GitHub και επικολλήστε το https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-precommit-codecheck. Το TypingMind διαβάζει το αρχείο SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία και εγκαθιστά τη δεξιότητα, την οποία μπορείτε να ενεργοποιείτε ανά συνομιλία.

Ποια μοντέλα AI μπορούν να χρησιμοποιήσουν τη δεξιότητα Oh Precommit Codecheck;

Οποιοδήποτε μοντέλο συνδέετε στο TypingMind. Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως τα GPT, Claude, Gemini, Grok και τα τοπικά μοντέλα μπορούν όλα να φορτώσουν αυτή τη δεξιότητα όταν ένα αίτημα αντιστοιχεί σε αυτή.

Με πόσα μοντέλα AI μπορώ να χρησιμοποιήσω τη Oh Precommit Codecheck;

Με όσα θέλετε. Εφόσον ένα μοντέλο υποστηρίζει δεξιότητες, μπορείτε να χρησιμοποιήσετε τη Oh Precommit Codecheck με αυτό — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama και άλλα — όλα στο TypingMind με τα δικά σας κλειδιά API.

Είναι δωρεάν η δεξιότητα AI Oh Precommit Codecheck;

Δημοσιεύεται στο GitHub από τον χρήστη openharmonyinsight. Ελέγξτε το αποθετήριο για τους όρους αδειοδότησης. Πληρώνετε μόνο τον δικό σας πάροχο AI για τα token που χρησιμοποιείτε.

Τι είναι οι δεξιότητες AI;

Μια δεξιότητα AI είναι ένα επαναχρησιμοποιήσιμο πακέτο οδηγιών που διδάσκει σε ένα μοντέλο AI πώς να εκτελεί μια συγκεκριμένη εργασία. Ακολουθεί την ανοιχτή μορφή Agent Skills: ένα αρχείο SKILL.md με όνομα και περιγραφή, μαζί με τυχόν σενάρια κώδικα, πρότυπα ή αρχεία αναφοράς που μπορεί να χρειαστεί το μοντέλο. Το μοντέλο διαβάζει τις οδηγίες μόνο όταν το αίτημά σας αντιστοιχεί στη δεξιότητα, οπότε μια εγκατεστημένη δεξιότητα δεν κοστίζει τίποτα μέχρι να χρησιμοποιηθεί.

Σε τι διαφέρουν οι δεξιότητες AI από τα πρόσθετα ή τους συνδέσμους MCP;

Ένα πρόσθετο ή ένας σύνδεσμος MCP παρέχει στο μοντέλο νέα εργαλεία που μπορεί να καλέσει — κώδικα που εκτελείται κάπου και επιστρέφει ένα αποτέλεσμα. Μια δεξιότητα AI παρέχει αντί γι’ αυτό γνώσεις και διαδικασίες στο μοντέλο: πώς να προσεγγίσει μια εργασία, ποια βήματα να ακολουθήσει και ποια χαρακτηριστικά έχει ένα καλό αποτέλεσμα. Οι δεξιότητες είναι απλό Markdown, επομένως δεν χρειάζονται διακομιστή, κλειδί API ή περιβάλλον εκτέλεσης και λειτουργούν με οποιοδήποτε μοντέλο.

Προβολή όλων

Στήστε δικό σας χώρο εργασίας AI τώρα

Εγγραφείτε στο ενημερωτικό μας δελτίο για να ενημερώνεστε για νέες λειτουργίες και μελλοντικές κληρώσεις δώρων 👇