Skip to main content

A standard for defining project rules and skills for AI agents.

Project description

Project Rules Generator

Python 3.8+ License: MIT Tests


The Problem

Every AI agent you use — Claude, Cursor, Windsurf, Copilot — starts every conversation knowing nothing about your project.

You explain your stack. Again. You correct the same bad patterns. Again. You watch it generate code that ignores your architecture. Again.

The AI isn't dumb. It's context-blind.


The Solution

Project Rules Generator (PRG) builds a persistent intelligence layer for your project — rules, skills, and patterns — that every AI agent reads automatically.

Run it once. Every future AI session starts with project context: your stack, your conventions, your architecture, your do's and don'ts.

cd your-project
prg init .

That's it. Your .clinerules/ is now the memory your AI agents never had.


What Gets Generated

.clinerules/
├── rules.md              ← Your coding conventions (tech-specific, auto-detected)
├── constitution.md       ← Non-negotiable principles ("never do X in this project")
├── clinerules.yaml       ← Skill index for agents that support it
└── skills/
    ├── project/          ← AI-generated workflows tailored to YOUR project
    ├── learned/          ← Reusable patterns, shared across projects
    └── builtin/          ← Battle-tested best practices, bundled

Project Lifecycle Generators (Optional):

  • spec.md: High-level Product Specifications and constraints (Goals, Stories).
  • DESIGN.md: Phase 1 Architecture Document detailing technical integrations.
  • PLAN.md & TASKS.json: Phase 2 AI-driven granular task decomposition.

Example rules.md output for a FastAPI project:

## FastAPI Rules (High Priority)
- Use async/await for ALL I/O — never block the event loop
- Pydantic models for every request/response body, no raw dicts
- Use Depends() for injection — never pass dependencies manually

## Testing Rules
- pytest fixtures for all setup; parametrize for edge cases
- Mock at boundaries only (APIs, DB) — never internal logic

No templates. No hand-holding. Generated from your actual project.


Quick Start

No API key needed — PRG works offline from your README and file structure:

pip install -e .
prg init .

With a free API key — LLM-generated skills and richer analysis:

export GROQ_API_KEY=gsk_...   # free at console.groq.com
prg analyze . --ai

Full autopilot or granular workflow — analyze, design, plan, code, commit, repeat:

prg analyze . --incremental            # 3-5x faster subsequent runs
prg design "Add OAuth2 login"          # Two-Stage Planning
prg autopilot . --provider anthropic   # Full automation loop

The 3-Layer Skill System

Skills are ranked by specificity. More specific always wins:

Layer Location What It Contains Written by Priority
Project .clinerules/skills/project/ Auto-generated by prg analyze from this project's README + context README flow Highest
Learned ~/.project-rules-generator/learned/ Reusable skills captured explicitly — default target of --create-skill --create-skill (default) Medium
Builtin ~/.project-rules-generator/builtin/ Universal patterns (mypy, git, Python idioms) --scope builtin Lowest

A project-level skill overrides the global one. Your patterns win.

Skill scope routing:

  • prg analyze → writes to project/ (project-context-aware, not reusable)
  • --create-skill → writes to learned/ by default (explicit capture = reusable)
  • --create-skill --scope builtin → writes to builtin/ for universal patterns

AI Providers

PRG auto-detects the best available provider from your environment. Set one key, or set several — it routes intelligently.

Provider Model Best For Key
Anthropic Claude Sonnet 4.6 Highest quality rules & skills ANTHROPIC_API_KEY
OpenAI GPT-4o-mini Solid all-rounder OPENAI_API_KEY
Gemini Gemini 2.0 Flash Fast + high quality GEMINI_API_KEY
Groq Llama 3.1 8b Free tier, fastest GROQ_API_KEY

No provider? PRG still works — README + file structure analysis is free and surprisingly smart.

prg providers list       # See what's configured
prg providers test       # Live latency check
prg providers benchmark  # Side-by-side quality ranking

All Features & Commands

🔍 1. Analysis & Generation

prg init .                                    # First-run wizard: detect stack, generate rules
prg analyze .                                 # Regenerate from README + file structure
prg analyze . --ai                            # AI-powered analysis (LLM-generated skills)
prg analyze . --incremental                   # Update only what changed (3–5x faster)
prg analyze . --constitution                  # Also generate constitution.md

🧠 2. Two-Stage Planning & Specs

prg design "Add OAuth2 login"                 # Stage 1: Generates DESIGN.md architecture document
prg plan   "Add OAuth2 login"                 # Stage 2: Generates PLAN.md + TASKS.json implementation plan
        # Note: spec.md is auto-generated if absent during planning

🛠️ 3. Skill Management

prg analyze . --create-skill "auth-flow" --ai             # Create a global learned/ reusable skill
prg analyze . --create-skill "mypy-types" --scope builtin # Create a universal builtin/ skill
prg skills list --all                                     # List project + learned + builtin skills
prg skills validate my-skill                              # Run quality checker (score must be ≥ 90)

🤖 4. Autonomous Orchestration

prg agent "fix a bug"                         # Smart Orchestration (Maps generic text to an exact skill)
prg review PLAN.md                            # AI Self-Review mode (Generates CRITIQUE.md scorecard)
prg autopilot .                               # Full autonomous loop (discover → plan → code → commit)

(Note: The Lifecycle Manager prg manager . is also theoretically available for complete setup → verify → execute → report cycles).


How Analysis Works

prg analyze . --ai
        │
        ▼
  Read README + file structure
        │
        ▼
  Detect tech stack (45+ technologies)
  fastapi · react · pytest · sqlalchemy · docker · ...
        │
        ▼
  AIStrategyRouter
  ┌─────────────────────────────────────────┐
  │  Has API key?  →  CoworkStrategy (LLM)  │
  │  Has README?   →  READMEStrategy        │
  │  Fallback      →  StubStrategy          │
  └─────────────────────────────────────────┘
        │
        ▼
  Quality gate (score ≥ 90) → auto-retry if needed
        │
        ▼
  .clinerules/rules.md + skills/

Rules are scored before they're written. Generic filler never makes it through.


Installation

git clone https://github.com/Amitro123/project-rules-generator
cd project-rules-generator
pip install -e .
prg --version

Requirements: Python 3.8+, Git


Contributing

# Run tests
pytest

# Format (required before commit)
black . && ruff check . && isort .
  1. Fork → feature branch → pytestblack . → PR
  2. Follow conventional commits: feat:, fix:, refactor:

See CLAUDE.md for architecture notes and docs/architecture.md for full diagrams.


License

MIT — see LICENSE.


Full version history: CHANGELOG.md · Architecture: docs/architecture.md · Feature deep-dives: docs/features.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

project_rules_generator-0.3.0.tar.gz (159.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

project_rules_generator-0.3.0-py3-none-any.whl (182.3 kB view details)

Uploaded Python 3

File details

Details for the file project_rules_generator-0.3.0.tar.gz.

File metadata

  • Download URL: project_rules_generator-0.3.0.tar.gz
  • Upload date:
  • Size: 159.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for project_rules_generator-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c55e864809df9a9df8187238384b5ba2f5be5fad6fe818a8ffdb1440c007c8c9
MD5 b2b1f0f5d050ee1076799599eb2d2f79
BLAKE2b-256 13ad000c6fad1d7a070a1cfcaed6516f185df2fb514fd2005590759e4627166b

See more details on using hashes here.

Provenance

The following attestation bundles were made for project_rules_generator-0.3.0.tar.gz:

Publisher: publish.yml on Amitro123/project-rules-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file project_rules_generator-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for project_rules_generator-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa7f38e9dc1b1589187799148c5b6174044e7e264c3d441e73d1c2a90088fa57
MD5 9b2ed376b5abfe2d1c6768dfcdcfa511
BLAKE2b-256 4e5d41124d6107f79c164b922edf7cddad162fd3fc972c17459b49265cbdddba

See more details on using hashes here.

Provenance

The following attestation bundles were made for project_rules_generator-0.3.0-py3-none-any.whl:

Publisher: publish.yml on Amitro123/project-rules-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page