Skip to main content

Generate and manage documentation and task tracking for Cursor IDE projects

Project description

Cursor Rules

A high-performance framework for managing custom instructions for AI assistants.

Installation

pip install dynamic-cursor-rules

For LLM integration features:

pip install dynamic-cursor-rules[llm]

Usage

from cursor_rules import RuleSet, Rule, parse_file, RuleExecutor

# Create a rule set
ruleset = RuleSet(name="My Rules", description="Custom rules for my assistant")

# Add some rules
ruleset.add_rule(Rule(
    content="Always respond in a friendly tone.",
    id="tone_friendly",
    priority=10,
    tags=["tone"]
))

# Save rules to a file
ruleset.save("my_rules.json")

# Load rules from different formats
markdown_ruleset = parse_file("rules.md")

# Apply rules in a production environment
executor = RuleExecutor(ruleset)
context = {
    "user_input": "Tell me about Python",
    "tags": ["programming"]
}
result = executor.apply_rules(context)
print(result["instructions"])

Features

  • Parse rules from Markdown, YAML, and JSON formats
  • Prioritize and tag rules for contextual application
  • Validate rule sets to ensure correctness
  • Apply rules within AI assistant workflows
  • Generate .cursorrules files for Cursor IDE integration
  • Extract and track tasks from project initialization documents
  • Generate complete documentation suites from initialization documents
  • Beautiful, interactive CLI with progress indicators and visual feedback
  • Simple and elegant API
  • Integration with LLM providers (OpenAI, Anthropic)

Rule Management

Markdown Format

# My Rules

Rules for my AI assistant

## Be Concise

Keep responses short and to the point.

## Use Examples

Provide concrete examples when explaining concepts.

YAML

name: My Rules
description: Rules for my AI assistant
rules:
  - id: be_concise
    content: Keep responses short and to the point.
    priority: 10
    tags: [style]
  - id: use_examples
    content: Provide concrete examples when explaining concepts.
    priority: 5
    tags: [teaching]

Task Tracking

Cursor Rules can extract and manage tasks from project initialization documents:

from cursor_rules import extract_action_plan_from_doc, synchronize_with_cursorrules

# Extract tasks from a markdown project document
action_plan = extract_action_plan_from_doc("project_init.md")

# List tasks by phase
for phase in action_plan.phases:
    print(f"Phase: {phase.title}")
    for task in phase.tasks:
        print(f"- {task.title} [Status: {task.status.name}]")

# Update task status
task = action_plan.get_task_by_id("task_id")
if task:
    task.status = TaskStatus.COMPLETED

# Save the action plan to a file
action_plan.save_to_file("project_tasks.json")

# Load an action plan from a file
loaded_plan = ActionPlan.load_from_file("project_tasks.json")

# Sync with a ruleset
ruleset = RuleSet.load("project_rules.json")
synchronize_with_cursorrules(action_plan, ruleset)

Command Line Interface

You can also manage tasks from the command line:

# Generate an action plan from a markdown file
cursor-tasks generate project_init.md -o project_tasks.json

# List all tasks
cursor-tasks list -f project_tasks.json

# List tasks by phase
cursor-tasks list -f project_tasks.json -p "Backend Development"

# Update task status
cursor-tasks update -f project_tasks.json -t task_id -s completed

# Sync with a ruleset
cursor-tasks sync -f project_tasks.json -r project_rules.json

Document Generation

Cursor Rules can generate a complete set of project documentation from a single initialization document:

from cursor_rules import DocumentGenerator

# Create a document generator
generator = DocumentGenerator("project_init.md")

# Generate all documents
generated_files = generator.generate_all_documents()

# Print the paths to generated files
for doc_name, file_path in generated_files.items():
    print(f"{doc_name}: {file_path}")

The generated documentation includes:

  • Product Requirements Document (PRD): Contains project vision, target users, user stories, and requirements
  • Technical Stack Document: Details the technology stack, architecture, and development environment based on the PRD
  • .cursorrules file: Provides project-specific rules for Cursor IDE derived from the PRD
  • Action Items: Structured development tasks organized by implementation phases

Document Generation Architecture

Cursor Rules uses a strict PRD-centric document generation approach:

  1. The initialization document is first parsed to create a comprehensive PRD
  2. The PRD then becomes the single source of truth for all other documents
  3. Action items are generated exclusively from the PRD, never from the initialization document
  4. The generation process requires LLM capabilities and will fail explicitly rather than using fallbacks
  5. All tasks and subtasks represent actual development work, organized by implementation phases
  6. This strict sequential workflow ensures consistency across all project documentation

Dynamic Rules

Cursor Rules includes a powerful dynamic rules system that automatically adapts to your project's changing state:

from cursor_rules import DynamicRuleManager, ProjectState, ProjectPhase, Component

# Create a project state
project_state = ProjectState(
    name="My Project",
    description="A dynamic project",
    phase=ProjectPhase.SETUP,
    tech_stack={"frontend": ["React"], "backend": ["Node.js"]}
)

# Create a dynamic rule manager
rule_manager = DynamicRuleManager("/path/to/project", project_state)

# Generate rules based on current project state
rule_files = rule_manager.generate_dynamic_rules()

# Update the project state as development progresses
rule_manager.update_project_state(
    phase=ProjectPhase.FEATURE_DEVELOPMENT,
    active_features=["authentication", "dashboard"]
)

# Regenerate rules to reflect the new state
updated_rule_files = rule_manager.generate_dynamic_rules()

Key Features of Dynamic Rules

  1. Project State Tracking: Monitors project phase, active features, components, and tech stack
  2. Adaptive Rule Generation: Creates different rule sets based on the current project state
  3. Code Change Detection: Automatically detects changes in the codebase and updates rules accordingly
  4. Phase-Specific Rules: Different rules for different project phases (setup, development, refinement, etc.)
  5. Rule Versioning: Maintains history of previous rule versions for reference and rollback
  6. Component-Aware Rules: Generates specific rules for different components of your application

Command Line Interface

# Update project state and regenerate rules
cursor-rules update-rules --phase feature_development --features "auth,dashboard"

# View current project state
cursor-rules state

# Force regeneration of all rules
cursor-rules update-rules --force

Command Line Interface

Generate documents with a beautiful, interactive interface:

# Generate all documentation from an initialization document
cursor-rules documents project_init.md

This creates:

  • A .cursor directory at the root with the .cursorrules file
  • A documentation directory with all project documents (PRD, Technical Stack, Tasks)
  • A development-log.md file to track changes

License

MIT

Examples

The package includes several example scripts to demonstrate its functionality:

# Complete workflow example demonstrating all features
python examples/complete_workflow_example.py

# Document generation from initialization document
python examples/document_generation_example.py

# Task manager example
python examples/task_manager_example.py

# Rule generation example
python examples/rule_generation_example.py

These examples demonstrate key features like:

  • Generating .cursorrules files from markdown documents
  • Creating complete documentation suites (PRD, Technical Stack, Tasks)
  • Extracting and managing tasks
  • Versioning .cursorrules files
  • Monitoring codebase changes
  • Working with LLM providers

API Key Configuration

For features that use LLM integration, you need to configure your API keys:

# Set up OpenAI API key
cursor-rules llm config --provider openai --api-key your_key_here

# Set up Anthropic API key
cursor-rules llm config --provider anthropic --api-key your_key_here

# List configured providers
cursor-rules llm list

# Test your configuration
cursor-rules llm test

You can also use environment variables:

# Linux/macOS
export OPENAI_API_KEY=your_key_here
export ANTHROPIC_API_KEY=your_key_here

# Windows PowerShell
$env:OPENAI_API_KEY = "your_key_here"
$env:ANTHROPIC_API_KEY = "your_key_here"

For detailed instructions, see the API Key Setup Guide.

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

dynamic_cursor_rules-1.7.8.tar.gz (88.6 kB view details)

Uploaded Source

Built Distribution

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

dynamic_cursor_rules-1.7.8-py3-none-any.whl (79.3 kB view details)

Uploaded Python 3

File details

Details for the file dynamic_cursor_rules-1.7.8.tar.gz.

File metadata

  • Download URL: dynamic_cursor_rules-1.7.8.tar.gz
  • Upload date:
  • Size: 88.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for dynamic_cursor_rules-1.7.8.tar.gz
Algorithm Hash digest
SHA256 9b4db5fc6c7f0069160b6b6d511095e6f877ed09463e42eeba5d413dd763a727
MD5 53600dfd13c8320a46f4a8fe19eb498b
BLAKE2b-256 5f9e6ac02466c95b5b48b363898b2983fa0bd7c72048cdf5cf5c05de14139e06

See more details on using hashes here.

File details

Details for the file dynamic_cursor_rules-1.7.8-py3-none-any.whl.

File metadata

File hashes

Hashes for dynamic_cursor_rules-1.7.8-py3-none-any.whl
Algorithm Hash digest
SHA256 02da285a88a8a052e5111f41931810a8bbd19177f1d9c2fdbb6a426fb6745de7
MD5 e8323b3033ace7e46171697f2c7fbaf8
BLAKE2b-256 b3062f60380e52326f7770bd4a96ae1e28b02ed5d0c43fb826fae0bba821358a

See more details on using hashes here.

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