@aialchemy/ai-coding-rules
v1.1.2
Published
Universal, tool-agnostic instruction packs for AI coding agents
Maintainers
Readme
ai-agentic-rules
Universal, tool-agnostic instruction packs for AI coding agents, plus tool-specific adapters.
CLI package: @aialchemy/ai-coding-rules (bin: ai-coding-rules)
What is this?
A modular system for defining how AI coding agents (and humans) should work in your codebase. Rules are organized into packs that can be combined via profiles, with explicit conflict resolution.
Philosophy
- Layered: Org-wide (
~/.ai-coding-rules/) → Repo (AGENTS.md) → Domain/folder rules - Tool-agnostic: Canonical rules live in packs; adapters are thin pointers
- Composable: Mix and match packs via profiles
- Explicit conflicts: Clear policy for resolving toolchain and rule conflicts
- Public-safe: No secrets, no internal URLs, no client names
- Human-owned: Your project context is never overwritten
Quick Start (Minimum Useful Setup)
Get started with a single command (npm v11+ requires an explicit binary):
# Option A (npx with explicit binary)
npx --yes --package=@aialchemy/ai-coding-rules ai-coding-rules init
# Option B (npm exec)
npm exec --yes --package=@aialchemy/ai-coding-rules -- ai-coding-rules initThat's it! This will:
- Download the latest rules and adapters from GitHub
- Prompt you to select a profile (bun-stack, node-stack, or mobile-stack)
- Prompt you to select which AI tools you use (Cursor, VS Code Copilot, Kiro, Gemini)
- Create a composed file structure that preserves your context
- Configure your selected tools automatically
Outcome: Governance rules active, tool configured, human context preserved.
What This Tool Does (and Doesn't Do)
✅ What it does:
- Governs how work happens (coding standards, conflict resolution, planning)
- Provides toolchain guidance (Bun vs Node, testing frameworks, etc.)
- Ensures consistency across your codebase
- Helps AI agents understand your project conventions
❌ What it doesn't do:
- Replace developers
- Write business logic
- Make architectural decisions for you
- Run code or deploy applications
CLI Modes
The CLI supports three modes for different use cases:
Compose Mode (Default)
ai-coding-rules init --mode=composeBehavior:
- Creates or updates
AGENTS.rules.md(system-managed) - Creates
AGENTS.mdonly if missing (shared entry point) - Creates
AGENTS.local.mdonly if missing (human-managed, never overwritten) - Never deletes or overwrites human content
Use case: Default setup for new and existing projects.
Replace Mode (Advanced)
ai-coding-rules init --mode=replaceBehavior:
- Fully regenerates
AGENTS.md - Requires explicit confirmation
- Displays a warning before proceeding
Use case: When you want to start fresh with a completely new configuration.
Check Mode (CI/Validation)
ai-coding-rules init --mode=checkBehavior:
- Does not write files
- Validates rule resolution
- Returns non-zero exit code on conflicts
- Validates pack availability and adapter configuration
Use case: CI/CD pipelines, validation before deployment.
Plan Command
Preview what would change without writing any files:
ai-coding-rules planOutput includes:
- Files to be created
- Files to be modified
- Files untouched
- Rule packs applied
- Conflict resolution decisions
Use case: High-trust feature for understanding impact before running.
Non-interactive options (CI-friendly)
You can skip prompts by providing explicit flags:
ai-coding-rules init --mode=compose --profile=bun-stack --tools=cursor,vscode
ai-coding-rules plan --profile=node-stack --tools=cursor,kiro,gemini
ai-coding-rules check --profile=mobile-stackFile Ownership
The CLI creates a composed file structure with clear ownership:
| File | Owner | Overwritten by CLI | | --------------- | ------ | ------------------ | | AGENTS.md | Shared | Only if missing | | AGENTS.rules.md | System | Yes | | AGENTS.local.md | Human | Never |
File Structure
AGENTS.md # Entry point (human-readable, references other files)
AGENTS.rules.md # System-managed (auto-generated, contains governance rules)
AGENTS.local.md # Human-managed (never overwritten, your project context)AGENTS.md (Entry Point)
# Agent Context
This file is the **canonical entry point** for AI coding agents working in this repo.
## Governance Rules (Auto-generated)
<!-- DO NOT EDIT -->
See: ./AGENTS.rules.md
## Project Context (Human-maintained)
See: ./AGENTS.local.mdAGENTS.local.md (Your Space)
Edit this file to add:
- Project overview and goals
- Architecture decisions
- Team-specific guidelines
- Domain-specific rules
- Any other project context
Important: This file is never overwritten by AI Agentic Rules.
Installation Options
Option 1: Interactive CLI (Recommended)
# Option A (npx with explicit binary)
npx --yes --package=@aialchemy/ai-coding-rules ai-coding-rules init
# Option B (npm exec)
npm exec --yes --package=@aialchemy/ai-coding-rules -- ai-coding-rules initIf you install the CLI globally, you can run ai-coding-rules init directly.
Option 2: Remote installer script
curl -fsSL https://raw.githubusercontent.com/aialchemylabs/ai-agentic-rules/main/install/install-from-remote.sh | bashThen run one of the commands above in your repo to configure it.
Option 3: Manual installation
Clone and install packs:
git clone https://github.com/aialchemylabs/ai-agentic-rules.git cd ai-agentic-rules ./install/install-to-home.shChoose a profile:
bun-stack: Bun-first tooling + TypeScript + coding standardsnode-stack: Node/pnpm/Vite/Jest + TypeScript + coding standardsmobile-stack: Android + iOS + coding standards
Create
AGENTS.mdin your repo root:# Agent Rules for This Repository Profile: bun-stack # Repo-specific overrides - Use Next.js App Router - Prefer shadcn/ui componentsSee
examples/sample-repo/AGENTS.mdfor a complete example.Configure your tool adapter:
- Cursor: Copy
adapters/cursor/rules/*.mdcto.cursor/rules/(create the folder if needed) - VS Code Copilot: See
adapters/vscode-copilot/copilot-instructions.md - Kiro: See
adapters/kiro/project.md - Gemini/Antigravity: See
adapters/antigravity-gemini/GEMINI.md
- Cursor: Copy
Structure
ai-agentic-rules/
├── packs/ # Canonical rule packs
│ ├── core/ # Universal agent behavior
│ ├── bun-first/ # Bun toolchain defaults
│ ├── typescript/ # TypeScript standards
│ ├── java/ # Java standards
│ ├── android/ # Android/Kotlin standards
│ ├── ios/ # iOS/Swift standards
│ ├── ai-coding-standards/ # Coding standards
│ └── profiles/ # Profile definitions
│ ├── bun-stack.md
│ ├── node-stack.md
│ └── mobile-stack.md
├── adapters/ # Tool-specific adapters
│ ├── cursor/
│ ├── vscode-copilot/
│ ├── kiro/
│ └── antigravity-gemini/
├── install/ # Installation scripts
│ ├── install-to-home.sh
│ ├── install-from-remote.sh
│ └── update.sh
└── examples/ # Example usage
└── sample-repo/
└── AGENTS.mdLayering
Rules are applied in this order (highest to lowest priority):
- Enforcement: CI checks, linters, typecheck, tests, build pipelines
- Org-wide rules:
~/.ai-coding-rules/packs/(if installed) - Repo rules:
.ai-coding-rules/directory in the repo - Domain/folder rules: Directory-specific overrides (if present)
- Local context:
AGENTS.local.md - Profile defaults: Pack combinations defined in profiles
See packs/core/RULES.md for the full conflict resolution policy.
Conflict Resolution
When multiple rule sources apply:
- Enforcement wins: CI/lint/tests override written guidance
- Specific beats general: Folder rules > repo rules
- Explicit precedence:
org > repo > folder > local - Profile decides toolchain:
bun-stack→ Bun,node-stack→ Node/pnpm/Vite - Match the repo: If repo already chose a toolchain, follow it
Pack Editing Guidance
- Core packs: canonical, do not edit directly.
- Org packs: fork and own for your company’s rules.
- Local overrides: use
AGENTS.local.mdor repo-level packs for project-specific context.
Precedence rule: org > repo > folder > local
Rule Pack Maturity
Each pack declares a maturity level in its metadata.json:
Pack Types
core— Canonical, rarely changed (e.g.,core,typescript,ai-coding-standards)opinionated— Stack-specific (e.g.,bun-first,android,ios)org— Company-owned (for org-specific packs)experimental— Evolving (for experimental features)
Editing Guidance
- Core packs should not be edited directly
- Org packs are expected to be forked
- Local overrides are supported and encouraged (via
AGENTS.local.md)
Profiles
bun-stack
packs/core— Universal agent behaviorpacks/bun-first— Bun toolchain (bun install/test/build/serve)packs/typescript— TypeScript strictnesspacks/ai-coding-standards— Coding standards
Toolchain: Bun, bun:sqlite, Bun.redis, Bun.sql, Bun.serve(), HTML imports
node-stack
packs/core— Universal agent behaviorpacks/typescript— TypeScript strictnesspacks/ai-coding-standards— Coding standards
Toolchain: Node.js, pnpm (preferred), Vite, Jest/Vitest, Express
mobile-stack
packs/core— Universal agent behaviorpacks/android— Android/Kotlin standardspacks/ios— iOS/Swift standardspacks/ai-coding-standards— Coding standards
Toolchain: Kotlin, Gradle, Android SDK / Swift, Xcode, SPM/CocoaPods
Tool Adapters
Cursor
From your consuming repo, copy adapter files from your ai-agentic-rules clone:
mkdir -p .cursor/rules
cp /path/to/ai-agentic-rules/adapters/cursor/rules/*.mdc .cursor/rules/The adapters point to AGENTS.md and installed packs.
CLI output: ✔ Cursor adapter applied → .cursor/rules/
VS Code Copilot
See adapters/vscode-copilot/copilot-instructions.md for setup instructions.
CLI output: ✔ VS Code Copilot adapter applied → .vscode/settings.json
Kiro
See adapters/kiro/project.md for configuration.
CLI output: ✔ Kiro adapter applied → .kiro/steering/project.md
Gemini/Antigravity
See adapters/antigravity-gemini/GEMINI.md for @include usage.
CLI output: ✔ Gemini adapter applied → GEMINI.md
Local Validation
Test install script
# Dry run (check what would be installed)
./install/install-to-home.sh --dry-run
# Install packs
./install/install-to-home.sh
# Verify packs are installed
ls -la ~/.ai-coding-rules/packs/Verify structure
# Check all required files exist
find packs adapters install examples -type f | sort
# Verify scripts are executable
test -x install/install-to-home.sh && echo "✓ install script is executable"
test -x install/update.sh && echo "✓ update script is executable"How a Consuming Repo Uses This
Using the CLI (Recommended)
# In your repo root (choose one)
npx --yes --package=@aialchemy/ai-coding-rules ai-coding-rules init
npm exec --yes --package=@aialchemy/ai-coding-rules -- ai-coding-rules init
# Or with explicit mode
npx --yes --package=@aialchemy/ai-coding-rules ai-coding-rules init --mode=compose
npx --yes --package=@aialchemy/ai-coding-rules ai-coding-rules init --mode=replace
npx --yes --package=@aialchemy/ai-coding-rules ai-coding-rules init --mode=check
# Plan what would change
npx --yes --package=@aialchemy/ai-coding-rules ai-coding-rules planThis automatically:
- Downloads the latest rules and adapters from GitHub
- Creates a composed file structure that preserves your context
- Creates
AGENTS.md,AGENTS.rules.md, andAGENTS.local.md - Configures your selected IDE tools
Manual setup
Install packs (optional, for org-wide use):
# Option A: Remote installer curl -fsSL https://raw.githubusercontent.com/aialchemylabs/ai-agentic-rules/main/install/install-from-remote.sh | bash # Option B: Clone and install git clone https://github.com/aialchemylabs/ai-agentic-rules.git cd ai-agentic-rules ./install/install-to-home.shCreate
AGENTS.mdin your repo:# Agent Rules Profile: bun-stack # Repo-specific rules - Use Next.js App Router - Prefer shadcn/uiConfigure your tool (e.g., Cursor):
mkdir -p .cursor/rules cp /path/to/ai-agentic-rules/adapters/cursor/rules/*.mdc .cursor/rules/Agents will:
- Read
AGENTS.mdfirst - Load profile packs from
~/.ai-coding-rules/packs/or repo's.ai-coding-rules/ - Apply repo-specific overrides from
AGENTS.local.md - Follow conflict resolution policy
- Read
Non-Functional Requirements
- Deterministic: All file writes are deterministic
- Idempotent: CLI can be run multiple times safely
- No silent destruction: Clear logs for every action
- Safe defaults: Safety over power
- Transparent: Every action is logged and explained
Support
If this project saved you time or helped improve your development workflow, consider supporting our work:
Sponsor us on GitHub — Buy us a coffee and help us continue building open-source tools for the AI coding community.
License
MIT License — see LICENSE file.
Contributing
This repository provides public-safe, tool-agnostic rule packs. Contributions should:
- Be explicit, testable, and short
- Avoid tool lock-in
- Include conflict resolution notes when introducing new packs
- Keep each
RULES.mdunder ~200-300 lines - Include
metadata.jsonfor new packs with appropriate maturity level
Guiding Principle
AI Agentic Rules should feel like guardrails, not handcuffs.
Speed with safety. Governance with respect.
