npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lvxiaohui/ai-rule

v1.0.3

Published

Compile one source of AI coding rules into configs for multiple AI editors

Readme

ai-rule

把一份 AI 编程规则源文件编译成多种 AI 编程工具需要的配置文件。

ai-rule 让你把项目规则统一维护在 .ai-rules/ 目录中,然后生成 Codex、Claude、Cursor、GitHub Copilot、Trae、Windsurf、Kiro、Cline、Roo、Antigravity 等工具各自需要的配置文件。

English documentation: README.en.md

为什么需要它

不同 AI 编程工具读取项目规则的位置和格式并不一样:

  • Codex CLI: AGENTS.md
  • Claude: CLAUDE.md
  • Cursor: .cursor/rules/*.mdc
  • GitHub Copilot: .github/copilot-instructions.md
  • Trae: .trae/rules/.trae/skills/
  • Windsurf: .windsurf/rules/
  • Kiro: .kiro/steering/
  • Cline: .clinerules/
  • Roo: .roo/rules/
  • Antigravity: .agents/rules/

有了 ai-rule,你只需要写一份规则源文件,就可以编译到各个工具对应的位置,避免重复维护多套内容。

安装

npm install -D @lvxiaohui/ai-rule

也可以不安装,直接使用:

npx ai-rule

源目录结构

默认读取项目根目录下的 .ai-rules/

.ai-rules/
+-- rules/
|   +-- behavior-rules.md
|   +-- project-rules.md
+-- skills/
|   +-- some-skill.md
+-- mcp/
    +-- config.json
  • rules/: 通用项目规则,Markdown 格式
  • skills/: 任务型技能说明,Markdown 或其他文本文件
  • mcp/: MCP 配置文件,默认读取 config.json

使用

npx ai-rule
npx ai-rule --target=all
npx ai-rule --target=codex
npx ai-rule --target=cursor,claude

也保留了兼容命令:

npx rulesmith --target=codex
npx ai-rules --target=codex

配置

当默认配置不够用时,可以在项目根目录创建 .ai-rules.config.json

{
  "sourceDir": ".ai-rules",
  "rulesDir": "rules",
  "skillsDir": "skills",
  "mcpDir": "mcp",
  "targets": ["codex", "cursor"]
}

也可以把同样的配置放到 package.jsonaiRules 字段中。

当配置了 targets 时,ai-rule 会把它作为默认生成目标。命令行传入的 --target 会覆盖配置文件中的 targets

清理旧配置

生成前可以使用 --clean 清理已知的 AI 工具配置输出:

npx ai-rule --target=cursor --clean

适合在切换编辑器配置、或者想让项目里的生成文件保持干净时使用。

注意:--clean 会删除已知的 AI 工具配置路径,例如 AGENTS.md.cursor/.trae/CLAUDE.md 等。请确认这些文件确实是可重新生成的配置文件。

API

const { compileProject } = require('@lvxiaohui/ai-rule');

compileProject({
  cwd: process.cwd(),
  target: ['codex', 'cursor'],
  clean: false
});

维护者发布

发布流程见 docs/releasing.md

License

MIT