Skip to content
Apothem
示例

自定义规则

为你的项目编写一条自定义常驻规则。

本示例添加一条项目特定的常驻规则,在所有文件中强制执行某一命名约定。

规则文件

---
name: "kebab-filenames"
description: "Enforce kebab-case filenames in the src/ tree"
pathFilter: ""
alwaysApply: true
---

# Kebab-case filenames

All new files created under `src/` MUST use kebab-case naming
(lowercase letters, digits, and hyphens only — no underscores,
no camelCase, no PascalCase).

**Correct:** `src/styles/button-group.css`, `src/components/nav-bar.css`
**Incorrect:** `src/styles/buttonGroup.css`, `src/components/NavBar.css`

When in doubt, err on the side of more hyphens.

将此文件保存到工具安装根目录内的 rules/kebab-filenames.md(Claude Code 适配器使用 ~/.claude/;其他情况下请替换为该工具的原生路径)。

验证规则格式正确

针对刚写入的规则文件运行 frontmatter 校验器。在 Apothem 检出目录中使用第一条命令,其中 PYTHONPATH=src 使该包可被导入。脚本安装之后源码位于 $HOME/.apothem/src 之下,此时请使用第二条命令:

# From an Apothem checkout
PYTHONPATH=src python -m apothem.conformity.gate --check frontmatter-grep ~/.claude/rules/kebab-filenames.md

# After a script install
PYTHONPATH="$HOME/.apothem/src" python -m apothem.conformity.gate --check frontmatter-grep ~/.claude/rules/kebab-filenames.md

格式正确的规则会报告干净的通过结果:

{
  "orchestrator": "conformity-gate",
  "passed": true,
  "grep_count": 1
}

传播到各工具

为每个已安装的工具各运行一次更新命令:

apothem update --harness claude-code
apothem update --harness cursor --project /path/to/project

On this page