
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
dynamic-cursor-rules
Advanced tools
Generate and manage documentation and task tracking for Cursor IDE projects
A high-performance framework for managing custom instructions and development workflows for AI assistants within the Cursor IDE.
# Standard installation
pip install dynamic-cursor-rules
# Installation with LLM support (required for most features)
pip install dynamic-cursor-rules[llm]
Cursor Rules helps structure AI-assisted development by generating foundational documents, creating context-specific AI rules, and managing development phases.
cursor-rules documents
): Start by generating a suite of project documents from an initialization file (e.g., project_init.md
). This creates:
documentation/product_requirements.md
(PRD)documentation/technical_stack.md
documentation/action_items.md
(Task checklist)documentation/action_items.json
(Machine-readable tasks, if parsing succeeds)documentation/development_log.md
api_documentation.md
, backend_structure.md
, etc..cursor/rules/
based on the project context.cursor-rules start-phase
): Select a phase from action_items.md
(e.g., "Project Setup"
) to begin work. This command:
documentation/Phase_X_Implementation_Plan.md
using an LLM..cursor/rules/Current_Phase_Focus.mdc
, an alwaysApply: true
rule telling the AI the current focus and referencing the implementation plan.Current_Phase_Focus.mdc
and other relevant rules (matched by globs
) provide context to the AI.cursor-rules complete-phase
): Once the phase's tasks are done, run this command. It:
[x]
) in documentation/action_items.md
.documentation/development_log.md
..cursor/rules/Current_Phase_Focus.mdc
rule.start-phase
for the next phase in action_items.md
.The documents
command bootstraps the project documentation using an LLM.
# Generate all documentation from an initialization document
cursor-rules documents path/to/your/project_init.md -o /path/to/project/root
This command generates the core documents and initial Cursor rules based on the provided initialization file. It uses a PRD-centric approach, where the generated PRD informs all subsequent document and rule creation.
Generated Files:
documentation/
: Contains PRD, Tech Stack, Action Items (MD/JSON), Dev Log, and any generated optional documents (API docs, etc.)..cursor/rules/
: Contains AI instruction rules (.mdc
files) tailored to the project..mdc
Files)These files, stored in .cursor/rules/
, guide the AI assistant.
Each .mdc
file must start with YAML front matter enclosed in ---
:
---
description: A clear, semantic description of WHEN and WHY this rule applies. Used by the AI to determine relevance, especially when alwaysApply is false. (Required, plain text)
globs: path/glob/**/*.py, another/pattern/*.js # Comma-separated string of file globs this rule applies to. (Required)
alwaysApply: false # Use lowercase 'true' or 'false'. true = always apply; false = apply based on globs/description. (Required)
---
# Rule Title (Human Readable)
## Rule Content Section 1
- Use standard Markdown for detailed instructions.
- Provide actionable guidance (Do this, avoid that).
- Include project-specific context.
### Good Example:
\`\`\`python
# Code demonstrating the desired pattern
print("Hello")
\`\`\`
### Bad Example:
\`\`\`python
# Code demonstrating an anti-pattern
pass # Avoid empty blocks
\`\`\`
## Rule Content Section 2
... more guidance ...
## File Context References
# Point to relevant files in your codebase or other rule files
@file: src/core/utils.py
@file: .cursor/rules/Python_Backend_Rules.mdc
description
: Essential for AI understanding. Explains purpose and applicability.globs
: Triggers automatic attachment when working on matching files (if alwaysApply: false
). Use specific patterns. Comma-separated string.alwaysApply
: If true
, the rule is always active. If false
, depends on globs
and AI assessment based on description
. Use lowercase true
/false
.# Title
& Content: Human-readable title and Markdown instructions appear after the closing ---
.@file:
: Crucial for providing concrete examples from the codebase or chaining related rules.The documents
command generates initial rules like:
General_Project_Guidelines.mdc
(alwaysApply: true
, includes project summary, phase, goals, structure)Python_Backend_Rules.mdc
, React_Frontend_Rules.mdc
) based on detected stack (alwaysApply: false
, specific globs
).Testing_Guidelines.mdc
, Security_Best_Practices.mdc
, etc.) (alwaysApply: false
, relevant globs
).The start-phase
command creates/overwrites .cursor/rules/Current_Phase_Focus.mdc
(alwaysApply: true
) to provide the AI with specific strategic guidance for the active development phase, linking to the detailed implementation plan. This file is removed by complete-phase
.
Manage the development workflow phases:
# Start work on a specific phase from action_items.md
# (Use the exact phase title string as the identifier)
cursor-rules start-phase "Project Setup and Environment Configuration"
# Mark a phase as completed
cursor-rules complete-phase "Project Setup and Environment Configuration"
start-phase
: Generates a detailed Phase_X_Implementation_Plan.md
and the Current_Phase_Focus.mdc
rule.complete-phase
: Updates checkboxes in action_items.md
, updates development_log.md
, removes Current_Phase_Focus.mdc
.(Note: The automatic updating of checkboxes in action_items.md
relies on parsing the Markdown file generated by the LLM. Verify its accuracy after running complete-phase
.)
Configure API keys for LLM providers (required for document generation and phase management features).
# Set up OpenAI API key
cursor-rules llm config --provider openai --api-key YOUR_OPENAI_KEY
# Set up Anthropic API key
cursor-rules llm config --provider anthropic --api-key YOUR_ANTHROPIC_KEY
# List configured providers where keys are stored
cursor-rules llm list
# Test connectivity to configured providers
cursor-rules llm test
Alternatively, use environment variables (OPENAI_API_KEY
, ANTHROPIC_API_KEY
).
.cursor/rules/
with foundational and tech-specific rules using LLM, based on project context..mdc
format with description
, globs
, alwaysApply
.start-phase
and complete-phase
commands to structure workflow.alwaysApply: true
rule (Current_Phase_Focus.mdc
) to guide the AI based on the active development phase.action_items.md
with interactive Markdown checkboxes.MIT
.cursorrules
files for Cursor IDE integration# My Rules
Rules for my AI assistant
## Be Concise
Keep responses short and to the point.
## Use Examples
Provide concrete examples when explaining concepts.
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]
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)
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
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:
Cursor Rules uses a strict PRD-centric document generation approach:
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()
# 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
Generate documents with a beautiful, interactive interface:
# Generate all documentation from an initialization document
cursor-rules documents project_init.md
This creates:
.cursor
directory at the root with the .cursorrules
filedocumentation
directory with all project documents (PRD, Technical Stack, Tasks)development-log.md
file to track changesMIT
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:
.cursorrules
files from markdown documents.cursorrules
filesFor 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.
FAQs
Generate and manage documentation and task tracking for Cursor IDE projects
We found that dynamic-cursor-rules demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.