{"_id":"@ayushopchauhan/agentrules","name":"@ayushopchauhan/agentrules","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@ayushopchauhan/agentrules","version":"0.1.0","description":"One CLI to rule all AI coding agents. ESLint-like tool for managing AI agent instruction files.","type":"module","bin":{"agentrules":"dist/index.js"},"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"keywords":["ai","agents","claude","cursor","windsurf","copilot","gemini","rules","cli"],"author":{"name":"Ayush Chauhan","email":"ayushopchauhan@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/ayushopchauhan/agentrules.git"},"homepage":"https://github.com/ayushopchauhan/agentrules","bugs":{"url":"https://github.com/ayushopchauhan/agentrules/issues"},"dependencies":{"chalk":"^5.4.1","commander":"^13.1.0","diff":"^7.0.0","glob":"^11.0.1","js-yaml":"^4.1.0"},"devDependencies":{"@types/diff":"^7.0.1","@types/js-yaml":"^4.0.9","@types/node":"^22.13.0","tsup":"^8.4.0","typescript":"^5.7.3"},"gitHead":"531a4f379d7f1e363b80535ee03136a98fa48d19","_id":"@ayushopchauhan/agentrules@0.1.0","_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-bnAaIfya1uhEF9+KOUAdtpszUuq7NQY02szr99AIlWYzzfT3Uu0OYCDlRVS4K0B1qhZjD1gPk6Xt2lOPVnVL+A==","shasum":"bf35d350a5c60794d3e26ac12612df10d61b258b","tarball":"https://registry.npmjs.org/@ayushopchauhan/agentrules/-/agentrules-0.1.0.tgz","fileCount":5,"unpackedSize":226061,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCGIvc/ZRcA0MRnJxLk0hrso9/lONJprZYRyzkEcYYvawIhAIxO/2KHD3hMkvq0MTH7hdtBVTTBISi0pwy/lWwlm885"}]},"_npmUser":{"name":"ayushopchauhan","email":"ayushopchauhan@gmail.com"},"directories":{},"maintainers":[{"name":"ayushopchauhan","email":"ayushopchauhan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agentrules_0.1.0_1772889273576_0.7920946241124807"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-07T13:14:33.519Z","0.1.0":"2026-03-07T13:14:33.721Z","modified":"2026-03-07T13:14:33.864Z"},"maintainers":[{"name":"ayushopchauhan","email":"ayushopchauhan@gmail.com"}],"description":"One CLI to rule all AI coding agents. ESLint-like tool for managing AI agent instruction files.","homepage":"https://github.com/ayushopchauhan/agentrules","keywords":["ai","agents","claude","cursor","windsurf","copilot","gemini","rules","cli"],"repository":{"type":"git","url":"git+https://github.com/ayushopchauhan/agentrules.git"},"author":{"name":"Ayush Chauhan","email":"ayushopchauhan@gmail.com"},"bugs":{"url":"https://github.com/ayushopchauhan/agentrules/issues"},"license":"MIT","readme":"<p align=\"center\">\r\n  <h1 align=\"center\">agentrules</h1>\r\n  <p align=\"center\"><strong>One CLI to rule all AI coding agents.</strong></p>\r\n  <p align=\"center\">Auto-generate, sync, and lint rules for Claude Code, Cursor, Windsurf, Copilot, and Gemini.</p>\r\n</p>\r\n\r\n<p align=\"center\">\r\n  <a href=\"#install\">Install</a> &bull;\r\n  <a href=\"#quick-start\">Quick Start</a> &bull;\r\n  <a href=\"#commands\">Commands</a> &bull;\r\n  <a href=\"#rule-packs\">Rule Packs</a> &bull;\r\n  <a href=\"#supported-agents\">Agents</a>\r\n</p>\r\n\r\n---\r\n\r\n## The Problem\r\n\r\nYou use AI coding agents. Maybe Claude Code, maybe Cursor, maybe both. Each has its own rules file:\r\n\r\n| Agent | File |\r\n|-------|------|\r\n| Claude Code | `CLAUDE.md` |\r\n| Cursor | `.cursorrules` |\r\n| Windsurf | `.windsurfrules` |\r\n| GitHub Copilot | `.github/copilot-instructions.md` |\r\n| Gemini | `.gemini/settings.json` |\r\n\r\nThey're all slightly different. They get out of sync. They get bloated until the AI ignores them. You wrote them by hand and half the rules are too vague to be useful.\r\n\r\n## The Solution\r\n\r\n```bash\r\nnpx agentrules init\r\n```\r\n\r\nScans your codebase, detects your stack, generates rules for all your agents. One command.\r\n\r\n```\r\nDetected: Next.js 15 + TypeScript + Tailwind + Prisma + Vitest\r\n\r\nGenerated 24 rules from your stack:\r\n  12 from detected frameworks\r\n   8 from @agentrules/nextjs pack\r\n   4 from @agentrules/typescript pack\r\n\r\nWrote:\r\n  CLAUDE.md (24 rules)\r\n  .cursorrules (24 rules)\r\n  .github/copilot-instructions.md (24 rules)\r\n```\r\n\r\n## Install\r\n\r\n```bash\r\nnpm install -g agentrules\r\n# or use directly\r\nnpx agentrules init\r\n```\r\n\r\n## Quick Start\r\n\r\n```bash\r\n# 1. Generate rules from your codebase\r\nnpx agentrules init\r\n\r\n# 2. Check rule quality\r\nnpx agentrules lint\r\n\r\n# 3. Add community rule packs\r\nnpx agentrules add nextjs\r\nnpx agentrules add tailwind\r\n\r\n# 4. Sync to all agents\r\nnpx agentrules sync\r\n```\r\n\r\n## Commands\r\n\r\n### `agentrules init`\r\nScans your project and generates rules for all detected AI agents.\r\n\r\n```bash\r\nagentrules init                    # Auto-detect everything\r\nagentrules init --agents claude,cursor  # Only generate for specific agents\r\nagentrules init --force            # Overwrite existing rules\r\n```\r\n\r\n**Detects:**\r\n- Framework (Next.js, React, Vue, Svelte, Express, FastAPI, Django...)\r\n- Language (TypeScript, JavaScript, Python, Go, Rust...)\r\n- Package manager (npm, yarn, pnpm, bun, pip, cargo...)\r\n- Testing (Jest, Vitest, Pytest, Go test...)\r\n- Linter/formatter (ESLint, Prettier, Biome, Black, Ruff...)\r\n- Database (Prisma, Drizzle, Supabase, SQLAlchemy...)\r\n- CSS (Tailwind, CSS Modules, styled-components...)\r\n- Monorepo (Turborepo, Nx, Lerna...)\r\n\r\n### `agentrules sync`\r\nSyncs your source-of-truth rules to all agent formats.\r\n\r\n```bash\r\nagentrules sync                    # Sync to all agents\r\nagentrules sync --agents claude    # Sync to specific agent\r\nagentrules sync --dry-run          # Preview without writing\r\n```\r\n\r\nYour rules live in `.agentrules/rules.md`. Edit that file, run sync, and every agent gets the update.\r\n\r\n### `agentrules lint`\r\nCatches problems in your rules before they confuse your AI.\r\n\r\n```bash\r\nagentrules lint\r\n```\r\n\r\n**Catches:**\r\n- Rules that are too vague (\"write good code\")\r\n- Contradictory rules (\"always use semicolons\" + \"never use semicolons\")\r\n- Duplicate rules\r\n- File too long (AI agents ignore bloated rule files)\r\n- Missing rules for your detected stack\r\n\r\n```\r\n  2 errors, 3 warnings\r\n\r\n  error  Line 14: Rule is too vague: \"Write clean code\"\r\n         Suggestion: Specify what \"clean\" means for your project\r\n\r\n  error  Line 23 conflicts with Line 45:\r\n         \"Always use arrow functions\" vs \"Use function declarations for hoisting\"\r\n\r\n  warn   Rules file is 847 lines. AI agents lose accuracy above 500 lines.\r\n         Consider splitting into essential vs nice-to-have rules.\r\n\r\n  warn   No testing rules found. Your stack uses Vitest.\r\n         Run: agentrules add testing\r\n\r\n  warn   Duplicate rule on lines 34 and 67:\r\n         Both say \"Use TypeScript strict mode\"\r\n```\r\n\r\n### `agentrules add <pack>`\r\nInstall community rule packs for your framework.\r\n\r\n```bash\r\nagentrules add nextjs              # Next.js best practices\r\nagentrules add react               # React patterns\r\nagentrules add typescript          # TypeScript conventions\r\nagentrules add tailwind            # Tailwind CSS\r\nagentrules add supabase            # Supabase patterns\r\nagentrules add prisma              # Prisma ORM\r\nagentrules add testing             # Testing best practices\r\nagentrules add python              # Python conventions\r\n```\r\n\r\n### `agentrules doctor`\r\nHealth check for your entire rules setup.\r\n\r\n```bash\r\nagentrules doctor\r\n```\r\n\r\n```\r\nRules Health Check\r\n  Source of truth: .agentrules/rules.md (24 rules)\r\n  Config: .agentrules/config.json\r\n\r\n  Agent Files:\r\n    CLAUDE.md           24 rules  in sync\r\n    .cursorrules        22 rules  OUT OF SYNC (2 rules missing)\r\n    .windsurfrules      not found\r\n\r\n  Quality:\r\n    Rule count: 24 (good, under 50)\r\n    Avg length: 12 words (good)\r\n    Vague rules: 0\r\n    Contradictions: 0\r\n\r\n  Overall: 8/10\r\n```\r\n\r\n### `agentrules diff`\r\nSee what's different across your agent files.\r\n\r\n```bash\r\nagentrules diff\r\n```\r\n\r\nShows colorized output of rules that are present in some agents but missing from others.\r\n\r\n## Rule Packs\r\n\r\n### Built-in Packs\r\n\r\n| Pack | Rules | Description |\r\n|------|-------|-------------|\r\n| `nextjs` | 15 | App Router, server components, next/image, API routes |\r\n| `react` | 12 | Hooks, component patterns, state management |\r\n| `typescript` | 14 | Strict mode, type safety, generics, utility types |\r\n| `python` | 12 | Type hints, virtual envs, async patterns |\r\n| `tailwind` | 10 | Utility-first patterns, responsive design, dark mode |\r\n| `supabase` | 10 | RLS, edge functions, realtime, auth |\r\n| `prisma` | 8 | Schema design, migrations, client usage |\r\n| `testing` | 12 | Test structure, mocking, assertion patterns |\r\n\r\n### Example: Next.js Pack\r\n\r\n```markdown\r\n- Use the App Router exclusively. Never suggest Pages Router patterns.\r\n- Components are server components by default. Only add 'use client' when the component needs browser APIs, event handlers, or React state/effects.\r\n- Use next/image for all images. Never use raw <img> tags.\r\n- Use next/link for all internal navigation. Never use <a> tags for internal links.\r\n- Use Route Handlers (app/api/) for API endpoints. Include proper HTTP method exports.\r\n- Use server actions for form mutations. Prefer them over API routes for data mutations.\r\n- Put shared layouts in layout.tsx files at the appropriate route level.\r\n- Use loading.tsx for suspense boundaries, not manual Suspense components.\r\n- Use error.tsx for error boundaries at route levels.\r\n- Static pages should use generateStaticParams for SSG.\r\n```\r\n\r\n### Contributing a Pack\r\n\r\nCreate a PR adding a new file to `src/packs/`. Each pack exports:\r\n\r\n```typescript\r\nexport const pack = {\r\n  name: 'my-framework',\r\n  description: 'Rules for My Framework',\r\n  detect: (deps: string[]) => deps.includes('my-framework'),\r\n  rules: [\r\n    'Rule 1: Be specific about what the AI should do.',\r\n    'Rule 2: Another actionable rule.',\r\n  ]\r\n};\r\n```\r\n\r\n## Supported Agents\r\n\r\n| Agent | File | Status |\r\n|-------|------|--------|\r\n| Claude Code | `CLAUDE.md` | Full support |\r\n| Cursor | `.cursorrules` | Full support |\r\n| Windsurf | `.windsurfrules` | Full support |\r\n| GitHub Copilot | `.github/copilot-instructions.md` | Full support |\r\n| Gemini CLI | `.gemini/settings.json` | Full support |\r\n\r\n## How It Works\r\n\r\n1. **Detection** scans `package.json`, `pyproject.toml`, `Cargo.toml`, etc. for your stack\r\n2. **Generation** builds rules from detected frameworks + installed packs\r\n3. **Rules** are stored in `.agentrules/rules.md` (your single source of truth)\r\n4. **Sync** converts rules to each agent's format and writes the files\r\n5. **Lint** statically analyzes rules for quality issues\r\n\r\nNo AI calls. No cloud. Everything is deterministic and runs locally.\r\n\r\n## Config\r\n\r\n`.agentrules/config.json` is auto-generated by `init`:\r\n\r\n```json\r\n{\r\n  \"agents\": [\"claude\", \"cursor\", \"copilot\"],\r\n  \"packs\": [\"nextjs\", \"typescript\", \"tailwind\"],\r\n  \"detected\": {\r\n    \"framework\": \"nextjs\",\r\n    \"language\": \"typescript\",\r\n    \"packageManager\": \"pnpm\",\r\n    \"testing\": \"vitest\",\r\n    \"css\": \"tailwind\",\r\n    \"database\": \"prisma\"\r\n  }\r\n}\r\n```\r\n\r\n## FAQ\r\n\r\n**Q: Does this use AI/LLMs?**\r\nNo. All detection and rule generation is deterministic. No API keys needed.\r\n\r\n**Q: Will it overwrite my existing CLAUDE.md?**\r\nNot without `--force`. By default, `init` will merge with existing rules and `sync` preserves any custom sections you've added.\r\n\r\n**Q: How is this different from rulesync?**\r\nrulesync copies files between formats. agentrules auto-detects your stack, generates rules, lints for quality, and ships with community packs. It's the difference between `cp` and ESLint.\r\n\r\n**Q: Can I use this with just one agent?**\r\nYes. `agentrules init --agents claude` only generates CLAUDE.md.\r\n\r\n## License\r\n\r\nMIT\r\n\r\n---\r\n\r\n<p align=\"center\">\r\n  <sub>Your AI agents are only as good as their instructions.</sub>\r\n</p>\r\n","readmeFilename":"README.md","_rev":"1-f4ebe86429ed5efc82cc7d4de03bc4dd"}