Cursor Rules Template: AI Agent Workflows for Precision Machining ERP Maintenance
Cursor rules template for building AI Agent workflows to analyze ERP logs and plan preventative maintenance for precision machining SMEs.
Target User
Developers building AI agent workflows for manufacturing SMEs leveraging ERP logs for preventative maintenance
Use Cases
- Analyze ERP logs to identify maintenance windows
- Predict machine wear patterns from KPI trends
- Generate maintenance tasks and work orders
- Schedule preventive maintenance with minimal human intervention
- Detect production anomalies that affect maintenance planning
Markdown Template
Cursor Rules Template: AI Agent Workflows for Precision Machining ERP Maintenance
framework: Python
version: 3.11
stack: PostgreSQL SQLAlchemy ERPLogs
role:
- Framework Role & Context: Build AI agent to analyze ERP logs and plan maintenance
- Code Style & Guides: Black and isort for Python code
- Architecture & Directory Rules: src/agents, src/pipelines, tests, configs
- Authentication & Security Rules: Use environment tokens; never store plain credentials
- Database & ORM: SQLAlchemy models Asset, MaintenanceEvent, WorkOrder
- Testing & Linting: pytest, pytest-cov, flake8
- Prohibited Actions & Anti-patterns: Do not modify ERP data directly; avoid OS commands
architecture:
- src/
- src/agents/
- src/pipelines/
- tests/
- configs/
database:
orm: SQLAlchemy
models:
- Asset
- MaintenanceEvent
- WorkOrder
security:
shieldedCommands: true
accessControls:
- api_token_auth
- role_based_access
testing:
- unit_tests: tests/agents
- integration_tests: tests/integration
- linting: make lint
antiPatterns:
- direct ERP writes without guardrails
- executing shell commands from prompts
- brittle SQL that bypasses constraints
usage:
- ingestion: parse erp_logs.csv to extract asset_id, last_maintenance, runtime_hours
- analysis: compute MTBF, MTTR, and remaining useful life estimates
- planning: generate MaintenanceEvent tasks and assign to maintenance teams
- execution: schedule via WorkOrder and push to ERP with approval gate
exampleCode:
- code: |
# Sample Python function to parse ERP log lines
def parse_log(line):
parts = line.strip().split(',')
return {
asset_id: parts[0],
timestamp: parts[1],
runtime_hours: int(parts[2]),
}Overview
This Cursor rules template defines a practical AI agent workflow for precision machining SMEs that leverages ERP logs to plan preventative maintenance. It targets a Python + PostgreSQL stack with SQLAlchemy, parsing asset and maintenance data to generate safe, auditable maintenance tasks and schedules. The rules emphasize Cursor AI as a helper for data-driven decision making while enforcing strong guardrails and security boundaries.
When to Use These Cursor Rules
- When ERP logs reveal asset runtimes, MTBF trends, or abnormal downtime that impacts maintenance planning
- When you need automated task generation and work order creation from data insights
- When you require auditable decision trails and safe AI actions in a manufacturing environment
- When audit and security policies mandate environment isolation and non destructive test runs
Copyable .cursorrules Configuration
framework: Python
version: 3.11
stack: PostgreSQL SQLAlchemy ERPLogs
role:
- Framework Role & Context: Build AI agent to analyze ERP logs and plan maintenance
- Code Style & Guides: Black and isort for Python code
- Architecture & Directory Rules: src/agents, src/pipelines, tests, configs
- Authentication & Security Rules: Use environment tokens; never store plain credentials
- Database & ORM: SQLAlchemy models Asset, MaintenanceEvent, WorkOrder
- Testing & Linting: pytest, pytest-cov, flake8
- Prohibited Actions & Anti-patterns: Do not modify ERP data directly; avoid OS commands
architecture:
- src/
- src/agents/
- src/pipelines/
- tests/
- configs/
database:
orm: SQLAlchemy
models:
- Asset
- MaintenanceEvent
- WorkOrder
security:
shieldedCommands: true
accessControls:
- api_token_auth
- role_based_access
testing:
- unit_tests: tests/agents
- integration_tests: tests/integration
- linting: make lint
antiPatterns:
- direct ERP writes without guardrails
- executing shell commands from prompts
- brittle SQL that bypasses constraints
usage:
- ingestion: parse erp_logs.csv to extract asset_id, last_maintenance, runtime_hours
- analysis: compute MTBF, MTTR, and remaining useful life estimates
- planning: generate MaintenanceEvent tasks and assign to maintenance teams
- execution: schedule via WorkOrder and push to ERP with approval gate
exampleCode:
- code: |
# Sample Python function to parse ERP log lines
def parse_log(line):
parts = line.strip().split(',')
return {
asset_id: parts[0],
timestamp: parts[1],
runtime_hours: int(parts[2]),
}
Recommended Project Structure
project-root/
├── app/
│ ├── __init__.py
│ ├── agents/
│ │ └─ maintenance_planner.py
│ ├── pipelines/
│ │ └─ erp_ingest.py
│ └── models/
│ ├── asset.py
│ ├── maintenance.py
│ └── workorder.py
├── tests/
│ ├── unit/
│ └── integration/
├── configs/
│ └── settings.yaml
├── requirements.txt
└── README.md
Core Engineering Principles
- Data provenance and traceability for ERP-driven decisions
- Explicit guardrails and safe AI prompts; no destructive actions
- Idempotent rule execution with clear rollback paths
- Strong typing and schema validation for ERP data ingestion
- E2E tests covering data parsing, rule interpretation, and task generation
Code Construction Rules
- Use SQLAlchemy ORM models Asset, MaintenanceEvent, and WorkOrder; avoid direct SQL strings
- Keep ERP ingestion in a separate pipeline module with strict data validation
- All AI-driven actions must route through a sign-off gate before affecting maintenance data
- Code must be formatted with Black and linted with flake8
- Do not rely on brittle pattern matching; prefer robust data transforms
Security and Production Rules
- Authenticate all API calls with tokens; rotate tokens regularly
- Never embed ERP credentials in code; use vault/secret management
- Limit ERP data access to asset and maintenance schemas only
- Run AI tasks in isolated containers; implement runtime sandboxing
Testing Checklist
- Unit tests for ERP log parsing and MTBF calculations
- Integration tests for ingestion + rule execution pipeline
- End-to-end tests simulating real ERP log feeds
- Static analysis and linting in CI
Common Mistakes to Avoid
- Assuming ERP data is clean or complete
- Hard-coding thresholds without validation
- Skipping audit trails for AI-driven actions
- Overloading the AI agent with disruptive commands
Related Cursor rules templates
Explore adjacent Cursor rules templates for similar stacks, workflows, and production constraints.
- Cursor Rules Template: Maintenance Management System with Cursor AI
- Cursor Rules Template: Django Subscription Box Platform
- Cursor Rules Template: IoT Water Monitoring with FastAPI & PostgreSQL
- Cursor Rules Template for AI Bookkeeping with Python FastAPI & PostgreSQL
FAQ
What is a Cursor Rules Template for ERP-based PM?
A Cursor Rules Template defines how Cursor AI analyzes ERP logs to plan preventative maintenance for precision machining assets, including data extraction, rule-based task generation, and safe execution patterns.
Which stack does this template target?
This template targets a Python + PostgreSQL stack with SQLAlchemy, using ERP logs for maintenance planning, task generation, and scheduling within Cursor AI workflows.
How do ERP logs feed Cursor AI?
ERP logs are ingested into a data pipeline; Cursor AI analyzes machine KPIs and usage patterns to propose PM tasks, with optional push to a maintenance system after review.
Where should the .cursorrules file live?
Place the .cursorrules file at the project root under ai-skills/cursor-rules-templates/{slug} to ensure Cursor AI loads the rules during agent execution.
What are forbidden actions?
Do not perform destructive database edits, avoid direct ERP changes without approvals, and do not execute OS commands from prompts.
What constitutes a safe testing workflow?
Use local/test databases, mock ERP feeds, and CI pipelines with unit, integration, and end-to-end tests to validate rule behavior before production.