跳到正文
cccskills
免费在 GitHub 公开中文介绍

Prek

了解如何运行 Carbon 的提交前检查工具 `prek`,可检查全部文件或指定文件,并处理 Jujutsu 工作区、自动改写文件的钩子及依赖或安全策略错误。

原文查看原文说明

Instructions for running prek, the Carbon pre-submit/style/lint checker, that *MUST* be run before submitting an change.

carbon-language/carbon-lang星标 33,929(GitHub 33,929 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 提交前检查所有文件
  • 只检查本次修改的文件
  • 在 Jujutsu 工作区运行检查
  • 自动格式化后复查文件

中文介绍

功能

本技能介绍如何运行 Carbon 的提交前格式和代码检查工具 prek。可以检查所有文件,也可以指定文件列表。在 Jujutsu 工作区中直接运行 prek 会失败,因为它要求标准 Git 仓库结构;此时可使用辅助脚本 ./scripts/jj_prek.sh 检查有改动的文件。clang-format 和 rumdl 等钩子会直接改写文件,因此即使文件已经修正,prek 仍可能以失败状态退出。技能说明了如何查看这些改动并重新运行检查。对于受限环境中的依赖解析或安全策略错误,还介绍了在命令前加上 gpkg 的处理方式。

适用场景

向 Carbon 项目提交改动前,需要检查格式和代码问题时,可以使用本技能。在 Jujutsu 中工作,或检查过程中有文件被改写并导致失败状态时也适用。

使用示例

  • “只用 prek 检查我修改过的文件。”
  • “在这个 Jujutsu 工作区运行提交前检查。”
  • “查看检查工具格式化过的文件,然后重新运行检查。”

注意事项

资料要求提交改动前运行 prek。Jujutsu 辅助脚本始终与 trunk 比较;如果当前改动基于其他书签,检查范围可能包含上游改动中的文件。在受限环境遇到依赖或安全策略错误时,可以在命令前加上 gpkg。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
A良好要求检查钩子所做的修改,并重新运行检查。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足需要 `prek`,受限环境可能需要 `gpkg`,但未说明安装步骤。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月26日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md1.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Prek

<!-- Part of the Carbon Language project, under the Apache License v2.0 with LLVM Exceptions. See /LICENSE for license information. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -->

prek is the Carbon pre-submit, style, and lint checker. Running it is mandatory before submitting any changes.

Running prek

To run prek on all files:

prek run -a

To validate a specific list of files:

prek run --files <files>

Running prek in a Jujutsu (jj) workspace

If you are working in a Jujutsu workspace, running prek directly will fail because it expects a standard Git repository structure. Instead, use the helper script:

./scripts/jj_prek.sh

This script runs prek on all files that have changed between trunk and your current Jujutsu @ change.

Note that the script always compares against trunk. If your change is based on another bookmark rather than on trunk, the script also checks the files changed by that underlying change, so a reported failure may not be in your own work.

Hooks that rewrite files

Some hooks, notably clang-format and rumdl, fix problems in place rather than only reporting them. When they do, prek reports a failure and exits non-zero even though the tree is now correct.

Re-run prek after any failure that modified files, and treat the second, clean run as the result. Review what it changed: a reflow is expected, but a content change may not be what you intended.

Prek dependency errors

[!TIP] If prek fails with an error about resolving dependencies or security policy, you may be running in a restricted environment where the special-purpose gpkg tool is required. Prefix the command with gpkg, for example: gpkg prek run -a or gpkg ./scripts/jj_prek.sh.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

本技能介绍如何使用命令行`gh`只读查看GitHub issue正文和评论,支持通过编号或URL定位,也可指定其他仓库,并说明如何提取大量评论。

  • 查看issue正文和评论
  • 通过URL读取issue
  • 查看其他仓库的issue
carbon-language/carbon-lang3.4万2026年10月26日 更新

Agent tools

免费有简介

本技能为在 Carbon 代码库中工作的 AI 助手规定文件查看、搜索和编辑工具,并说明临时文件的存放与清理规则,以及何时可以编写和运行自定义程序。

  • 按规定工具搜索Carbon文件
  • 为文件编辑选择专用工具
  • 确认临时文件的存放与清理规则
carbon-language/carbon-lang3.4万2026年10月26日 更新

Bazel usage

免费有简介

了解如何在 Carbon 项目中通过 Bazelisk 构建、测试和运行程序,包括指定目标、启用 ASan,以及系统依赖变更后重建缓存。

  • 构建 Carbon 代码
  • 运行与修改相关的测试
  • 启动 Bazel 构建的程序
carbon-language/carbon-lang3.4万2026年10月26日 更新

Builtin functions

免费有简介

本技能介绍如何为Carbon编译器添加内置函数,包括类型注册、签名验证、常量求值、运行时LLVM IR生成、Prelude绑定,以及使用最小Prelude编写针对性测试。

  • 注册内置函数
  • 实现常量求值
  • 添加LLVM IR生成
carbon-language/carbon-lang3.4万2026年10月26日 更新

Code style

免费有简介

了解 Carbon 工具链对 Bazel、C++、Carbon、Markdown 和 Python 文件的格式规范,并查看注释、文档、命名、设计及提交说明的写作要求。

  • 整理 Carbon 代码格式
  • 检查注释和文档
  • 确认名称是否符合实际含义
carbon-language/carbon-lang3.4万2026年10月26日 更新

Diagnostics

免费有简介

本技能介绍如何在Carbon工具链中添加或修改错误和警告,包括注册诊断类型、用带类型的参数构造消息、为源码位置添加标签和上下文,以及检查措辞规范和测试覆盖。

  • 添加诊断消息
  • 为源码位置添加标签
  • 统一诊断措辞
carbon-language/carbon-lang3.4万2026年10月26日 更新

查看 carbon-language 的全部技能

报告此技能的问题