hairy by hairyf/skills
npx skills add https://github.com/hairyf/skills --skill hairy此技能涵盖了 Hairyf 在 Web 开发中偏好的工具、配置和最佳实践。此技能带有个人观点。
| 类别 | 偏好 |
|---|---|
| 包管理器 | pnpm |
| 语言 | TypeScript(严格模式) |
| 模块系统 | ESM ("type": "module") |
| 代码检查与格式化 | @antfu/eslint-config(不使用 Prettier) |
| 测试 | Vitest |
| Git 钩子 | simple-git-hooks + lint-staged |
| 文档 | VitePress(位于 docs/ 目录下) |
应尽可能遵循的高层次跨领域偏好设置:
当任务被标记为 "specify" 时(例如:"specify this repo according to hairy"):
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
@skills/arch-upkeep 和相关 arch-* 技能进行架构检测和升级规划。@skills/unjs 优先选择 unjs 生态系统)。@skills/taze 进行依赖项新鲜度检查和升级。lint + typecheck(如果存在测试,也包括测试)。@skills/unjs 并遵循其建议。arch-* 技能arch-* 栈(tsdown 库、CLI、monorepo、unplugin、webext、vscode 等)。@skills/arch-upkeep 来:
arch-* 目标技能。taze 保持依赖项新鲜taze(参见 @skills/taze)来:
package.json 中的版本,除非有特定理由不遵循 taze 的建议。nr lint → 通过 @antfu/eslint-config 运行 ESLint。nr typecheck → 严格模式下的 TypeScript(项目范围)。lint。main 推送时运行 lint 和 typecheck。使用 pnpm 作为包管理器。
对于 monorepo 设置,使用 pnpm 工作区:
# pnpm-workspace.yaml
packages:
- 'packages/*'
在 pnpm-workspace.yaml 中使用 pnpm 命名目录来管理依赖项版本:
| 目录 | 用途 |
|---|---|
prod | 生产依赖项 |
inlined | 由打包工具内联的依赖项 |
dev | 开发工具(代码检查器、打包工具、测试、开发服务器) |
frontend | 打包到前端的库 |
目录名称不限于上述内容,可以根据需要进行调整。避免使用默认目录。
使用 @antfu/ni 来统一包管理器命令。它会根据 lockfile 自动检测包管理器(pnpm/npm/yarn/bun)。
| 命令 | 描述 |
|---|---|
ni | 安装依赖项 |
ni <pkg> | 添加依赖项 |
ni -D <pkg> | 添加开发依赖项 |
nr <script> | 运行脚本 |
nu | 升级依赖项 |
nun <pkg> | 卸载依赖项 |
nci | 干净安装(类似 pnpm i --frozen-lockfile) |
nlx <pkg> | 执行包(类似 npx) |
如果找不到命令,请使用 pnpm i -g @antfu/ni 全局安装。
始终启用严格模式使用 TypeScript。
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
}
}
始终在 ESM 模式下工作。在 package.json 中设置 "type": "module"。
使用 @antfu/eslint-config 进行格式化和代码检查。这消除了对 Prettier 的需求。
创建带有 // @ts-check 注释的 eslint.config.js:
// @ts-check
import antfu from '@antfu/eslint-config'
export default antfu()
将脚本添加到 package.json:
{
"scripts": {
"lint": "eslint ."
}
}
当出现代码检查错误时,尝试使用 nr lint --fix 修复它们。不要添加 lint:fix 脚本。
使用 simple-git-hooks 和 lint-staged 进行预提交代码检查:
{
"simple-git-hooks": {
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
},
"scripts": {
"prepare": "npx simple-git-hooks"
}
}
使用 Vitest 进行单元测试。
{
"scripts": {
"test": "vitest"
}
}
约定:
foo.ts → foo.test.ts(同一目录)tests/ 目录中describe 和 it API(而不是 test)expect API 进行断言assert 用于 TypeScript 空值断言toMatchSnapshottoMatchFileSnapshot(将这些文件从代码检查中排除)对于库项目,通过由 bumpp 触发的 GitHub Releases 发布:
{
"scripts": {
"release": "bumpp -r"
}
}
使用 VitePress 编写文档。将文档放在 docs/ 目录下。
docs/
├── .vitepress/
│ └── config.ts
├── index.md
└── guide/
└── getting-started.md
将脚本添加到 package.json:
{
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs"
}
}
| 主题 | 描述 | 参考 |
|---|---|---|
| 优先选择 unjs 生态系统 | 优先选择 unjs 生态系统框架和工具;委托给 @skills/unjs | core-unjs-preferences |
| 通过 arch-* 进行架构设计 | 将仓库形态映射到规范的 arch-* 技能,并通过 arch-upkeep 升级 | core-arch-upkeep-routing |
| 使用 taze 保持依赖项新鲜 | 使用 taze 和受控升级持续保持依赖项新鲜 | core-deps-taze |
| 以 lint + typecheck 作为关卡 | 始终在本地和 CI 中以 lint + typecheck 结束 | core-lint-typecheck |
| 主题 | 描述 | 参考 |
|---|---|---|
| @antfu/eslint-config | 用于格式化和代码检查的 ESLint 扁平配置 | antfu-eslint-config |
| VS Code 扩展 | 推荐的开发扩展 | vscode-extensions |
| 主题 | 描述 | 参考 |
|---|---|---|
| 应用开发 | 针对 Vue/Vite/Nuxt/UnoCSS Web 应用程序的偏好设置 | app-development |
每周安装量
293
仓库
GitHub 星标数
6
首次出现时间
2026年1月29日
安全审计
安装于
cursor292
claude-code264
github-copilot48
codex48
opencode48
gemini-cli47
This skill covers Hairyf's preferred tooling, configurations, and best practices for web development. This skill is opinionated.
| Category | Preference |
|---|---|
| Package Manager | pnpm |
| Language | TypeScript (strict mode) |
| Module System | ESM ("type": "module") |
| Linting & Formatting | @antfu/eslint-config (no Prettier) |
| Testing | Vitest |
| Git Hooks | simple-git-hooks + lint-staged |
| Documentation | VitePress (in docs/) |
High-level cross-cutting preferences that should be respected whenever possible:
When a task is marked with "specify" (for example: "specify this repo according to hairy"):
@skills/arch-upkeep and the relevant arch-* skills.@skills/unjs).@skills/taze.lint + typecheck (and tests if present) before considering the "specify" task done.@skills/unjs and follow its recommendations.arch-* skillsarch-* stacks (tsdown library, CLI, monorepo, unplugin, webext, vscode, etc.).@skills/arch-upkeep to:
arch-* skill(s).tazetaze (see @skills/taze) to:
package.json unless there is a specific reason not to follow taze’s suggestions.nr lint → ESLint via @antfu/eslint-config.nr typecheck → TypeScript in strict mode (project-wide).lint on staged files.lint and typecheck on PRs and main pushes.Use pnpm as the package manager.
For monorepo setups, use pnpm workspaces:
# pnpm-workspace.yaml
packages:
- 'packages/*'
Use pnpm named catalogs in pnpm-workspace.yaml to manage dependency versions:
| Catalog | Purpose |
|---|---|
prod | Production dependencies |
inlined | Dependencies inlined by bundler |
dev | Development tools (linter, bundler, testing, dev-server) |
frontend | Frontend libraries bundled into frontend |
Catalog names are not limited to the above and can be adjusted based on needs. Avoid using default catalog.
Use @antfu/ni for unified package manager commands. It auto-detects the package manager (pnpm/npm/yarn/bun) based on lockfile.
| Command | Description |
|---|---|
ni | Install dependencies |
ni <pkg> | Add dependency |
ni -D <pkg> | Add dev dependency |
nr <script> | Run script |
nu | Upgrade dependencies |
nun <pkg> | Uninstall dependency |
Install globally with pnpm i -g @antfu/ni if the commands are not found.
Always use TypeScript with strict mode enabled.
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
}
}
Always work in ESM mode. Set "type": "module" in package.json.
Use @antfu/eslint-config for both formatting and linting. This eliminates the need for Prettier.
Create eslint.config.js with // @ts-check comment:
// @ts-check
import antfu from '@antfu/eslint-config'
export default antfu()
Add script to package.json:
{
"scripts": {
"lint": "eslint ."
}
}
When getting linting errors, try to fix them with nr lint --fix. Don't add lint:fix script.
Use simple-git-hooks with lint-staged for pre-commit linting:
{
"simple-git-hooks": {
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
},
"scripts": {
"prepare": "npx simple-git-hooks"
}
}
Use Vitest for unit testing.
{
"scripts": {
"test": "vitest"
}
}
Conventions:
foo.ts → foo.test.ts (same directory)tests/ directory in each packagedescribe and it API (not test)expect API for assertionsassert only for TypeScript null assertionstoMatchSnapshot for complex output assertionstoMatchFileSnapshot with explicit file path and extension for language-specific output (exclude those files from linting)For library projects, publish through GitHub Releases triggered by bumpp:
{
"scripts": {
"release": "bumpp -r"
}
}
Use VitePress for documentation. Place docs under docs/ directory.
docs/
├── .vitepress/
│ └── config.ts
├── index.md
└── guide/
└── getting-started.md
Add script to package.json:
{
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs"
}
}
| Topic | Description | Reference |
|---|---|---|
| Prefer unjs ecosystem | Prefer unjs ecosystem frameworks and tooling; delegate to @skills/unjs | core-unjs-preferences |
| Architecture via arch-* | Map repo shape to canonical arch-* skills and upgrade via arch-upkeep | core-arch-upkeep-routing |
| Fresh dependencies with taze | Keep dependencies continuously fresh using taze and controlled upgrades | core-deps-taze |
| Topic | Description | Reference |
|---|---|---|
| @antfu/eslint-config | ESLint flat config for formatting and linting | antfu-eslint-config |
| VS Code Extensions | Recommended extensions for development | vscode-extensions |
| Topic | Description | Reference |
|---|---|---|
| App Development | Preferences for Vue/Vite/Nuxt/UnoCSS web applications | app-development |
Weekly Installs
293
Repository
GitHub Stars
6
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
cursor292
claude-code264
github-copilot48
codex48
opencode48
gemini-cli47
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
nciClean install (like pnpm i --frozen-lockfile) |
nlx <pkg> | Execute package (like npx) |
| Lint + typecheck as gate | Always finish with lint + typecheck locally and in CI | core-lint-typecheck |