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 cursor-rules

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
  • Simple and elegant API

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: Contains project vision, target users, user stories, and requirements
  • Technical Stack Document: Details the technology stack, architecture, and development environment
  • .cursorrules file: Provides project-specific rules for Cursor IDE
  • Action Items: Tasks and subtasks organized by phase (in JSON and Markdown formats)

Command Line Interface

You can also generate documents from the command line:

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

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

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.0.0.tar.gz (58.3 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.0.0-py3-none-any.whl (49.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynamic_cursor_rules-1.0.0.tar.gz
  • Upload date:
  • Size: 58.3 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.0.0.tar.gz
Algorithm Hash digest
SHA256 8c3674ab593ad5a4c6542c75d248fe8fafb799eb01d06d4dab60b411ba0007cc
MD5 2007d49d616564142fac1b574470ea68
BLAKE2b-256 2cf4b964d56317ef7fda515f9317ee56c51a25fd5d3020dcc80d23260e6da108

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dynamic_cursor_rules-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0abad50ba261be07a7d49171130a2b6aefce3ef5b90376b283ea250faa2c4af
MD5 e12b32d30bf1f98aad640b0a32a3ffd0
BLAKE2b-256 e8c79df3b597ae2e2c9837bd57fb1004395cef97038400f3fe9bc98dea77fca2

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