skills/enforce-lf/SKILL.md
Enforce consistent LF line endings across platforms with a four-layer guard: .gitattributes, .editorconfig, Prettier endOfLine, and lint-staged pre-commit formatting. Targets pnpm + Prettier + simple-git-hooks projects.
npx skillsauth add adonis0123/adonis-skills enforce-lfInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
在 pnpm + Prettier + simple-git-hooks 项目中一键部署四层跨平台 LF 行尾守卫,确保 Windows/macOS/Linux 协作时行尾始终为 LF。
| 层级 | 文件 | 作用 | 触发时机 |
|------|------|------|----------|
| 1 | .gitattributes | Git 层:checkout/commit 时强制 LF | git checkout / git add |
| 2 | .editorconfig | 编辑器层:新建/保存文件时使用 LF | 文件编辑 |
| 3 | .prettierrc.json | 格式化层:prettier --write 时转换为 LF | 手动或自动格式化 |
| 4 | package.json (lint-staged + simple-git-hooks) | 提交层:pre-commit 钩子自动格式化 | git commit |
在项目根目录确认以下条件:
package.jsonpnpm-lock.yaml 或 pnpm-workspace.yaml)从现有代码推断以下变量,用于配置模板:
.editorconfig、.prettierrc.json 或 package.json 中的 tabWidth,默认 2*.{ts,tsx,js,mjs,jsx,json,css,md}package.json 中 simple-git-hooks.pre-commit,用于后续合并.gitattributes目标内容(追加到文件顶部):
# Force LF line endings for all text files
* text=auto eol=lf
合并策略:
.gitattributes(如果存在)* text=auto eol=lf,已有则跳过.editorconfig目标内容:
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = {indent_size}
trim_trailing_whitespace = true
合并策略:
.editorconfig,直接创建[*] section 包含 end_of_line = lfindent_size、indent_style 等).prettierrc.json目标内容(合并到现有配置):
{
"endOfLine": "lf"
}
合并策略:
.prettierrc.json(如果存在),合并 "endOfLine": "lf",保留其他字段endOfLine 的配置文件apps/*/ 和 packages/*/ 下是否有独立的 .prettierrc.json,同样合并 endOfLine.prettierrc(YAML 格式)或 prettier.config.js 等其他格式,告知用户手动添加 endOfLine: "lf" 配置package.json(lint-staged + simple-git-hooks)目标配置(合并到根 package.json):
{
"devDependencies": {
"lint-staged": "^16.3.2",
"prettier": "^3.8.1",
"simple-git-hooks": "^2.13.1"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged && {existing_pre_commit_commands}"
},
"lint-staged": {
"{lint_staged_glob}": "prettier --write --end-of-line lf"
}
}
合并策略:
pnpm lint-staged 追加到前面(用 && 连接)lint-staged,不重复添加simple-git-hooks 字段,创建完整配置--end-of-line lf 参数package.json 内的 lint-staged 配置,不处理独立的 .lintstagedrc 文件。如果检测到独立配置文件,告知用户手动迁移pnpm install
pnpm exec simple-git-hooks
pnpm install 会自动安装新增的 devDependencies。simple-git-hooks 命令将 package.json 中的 hook 配置写入 .git/hooks/。
逐项检查以下内容并向用户报告结果:
.gitattributes 包含 * text=auto eol=lf.editorconfig 的 [*] section 包含 end_of_line = lf.prettierrc.json 包含 "endOfLine": "lf"package.json 中 lint-staged 配置的 prettier 命令包含 --end-of-line lfpackage.json 中 simple-git-hooks.pre-commit 包含 lint-staged.git/hooks/pre-commit 文件存在且可执行可选的端到端测试:
# 创建一个测试文件,验证 pre-commit hook 能正常触发
echo "test" > /tmp/lf-test.txt && git add /tmp/lf-test.txt 2>/dev/null
git commit --allow-empty -m "test: verify pre-commit hook"
prettier --write --end-of-line lf . 对全仓库做一次格式化,统一存量文件.gitattributes 的 text=auto 会自动识别并跳过development
Use this skill when the user wants to set, write, or use a goal or /goal that makes a coding agent keep working until a verifiable done condition is met. This skill configures the autonomy and stopping contract for Codex, Claude Code, or portable agent prompts; it does not perform the underlying task. Trigger on requests like 'should I set a goal?', 'set up a durable goal', 'give me a /goal prompt', 'keep refactoring until tests pass', 'I am stepping away, have the agent finish this', or goal prompts for migrations, refactors, ports, spec implementations, eval loops, backlog cleanup, or multi-checkpoint work. Do not use for single quick edits, running tests once, OKR/scrum goal questions, recurring reminders, or token-budget settings.
testing
Create safe Git feature or hotfix branches with concise names. Use this whenever the user asks to create a branch, start work on a new feature or fix, wants a `feat/...` or `hotfix/...` branch name, asks for a short branch slug from a task description, or wants help before beginning local Git work. Default to recommending the branch name and command first, then create only after user confirmation. Do not push, commit, rebase, or create PRs.
tools
Use when the user's pain is "adding/removing one more X means editing N files" and X is a recurring variant kind: popup, banner, modal, ad slot, payment method, AI model/tool, form field type, connector, sub-site, command, menu item, agent, extension point, or data source. Use when they want to design, refactor, review, name, or explain a pluggable mechanism using registry, interface/trait contract, runtime core, and convention folders; mention pluginize, pluggable, plugin architecture, extension point, registry pattern, or extensibility. Use when explaining the first-principles rationale, DDD/SOLID/OCP mapping, or industry analogies behind that structure. Use for cross-stack mapping to VSCode contributes, Webpack/Vite plugins, Rust/Tauri connectors, Python entry_points, or cargo features. Skip one variant's internals/styles/hooks/copy/bugs, and skip register/registry meaning DI container, user signup, or package registry.
development
Use BEFORE heavier workflow skills when route choice matters. Route creative work without a design doc/spec to Brainstorm; destructive or hard-to-reverse work to Discuss; unresolved decisions, Plan/Full fan-out, ship checks, unclear bugs, and fresh-eyes fix-then-re-review need this gate. Skip single-line read-only lookups, pure typo/formatting edits, trivial safe one-line fixes, and clearly safe named-skill requests. Outputs Route, Runtime skill, Fallback alias, and Execution path.