Cursor Rules Template: Precision Machining ERP Maintenance with Cursor AI
Cursor Rules Template for building AI Agent workflows that analyze ERP logs to plan preventative maintenance in precision machining SMEs, powered by Cursor AI.
Target User
Developers building AI Agent workflows for manufacturing ERP data
Use Cases
- Ingest ERP logs from manufacturing equipment and processes
- Identify predictors of asset failure and schedule preventative maintenance
- Generate maintenance work orders and parts planning
- Feed maintenance tasks into ERP/MES systems with audit trails
- Audit AI decisions with human-in-the-loop
Markdown Template
Cursor Rules Template: Precision Machining ERP Maintenance with Cursor AI
Overview
Direct answer: This Cursor Rules Template configures an AI Agent to ingest ERP logs from precision machining SMEs, reason about maintenance needs, and propose preventative maintenance plans. It targets a Python 3.11+ stack with FastAPI, PostgreSQL, and SQLAlchemy ORM to model maintenance data and actions, all orchestrated by Cursor AI.
The Cursor rules configuration furnishes guidelines the AI must follow to interpret ERP data, surface maintenance decisions with auditability, and keep production-safe AI operations. It is designed to be copy-pasted into a project root as a starting point for a production-ready workflow.
When to Use These Cursor Rules
- You have ERP logs (machine telemetry, preventive maintenance history, spare parts usage) and want AI-generated maintenance recommendations.
- You need deterministic AI behavior for scheduling work orders and aligning with inventory in an SME manufacturing environment.
- You require clear boundaries between data access, business logic, and AI decision prompts to facilitate auditing.
- You want to model maintenance decisions using a SQL-based ORM and a REST API layer for integration with MES/ERP systems.
- You are building an edge-friendly, containerized solution where Cursor AI rules control agent actions and data flow.
Copyable .cursorrules Configuration
# Cursor Rules Template for Precision Machining ERP Maintenance
# Framework Role & Context
framework_role_and_context:
framework: 'Python 3.11+, FastAPI, SQLAlchemy, PostgreSQL'
runtime: 'Dockerized microservice; Cursor AI agent runs in container; ERP logs read from data/erp-logs'
context: 'AI Agent workflows for Precision Machining SMEs using ERP logs to plan preventative maintenance'
# Code Style and Style Guides
code_style_and_style_guides:
- 'PEP8'
- 'Black'
- 'isort'
# Architecture & Directory Rules
architecture_and_directory_rules:
project_root: '/'
dirs:
- 'app/'
- 'ai/'
- 'data/erp-logs'
- 'migrations/'
packaging: 'requirements.txt / pyproject.toml'
deployment: 'Docker, docker-compose'
# Authentication & Security Rules
authentication_and_security_rules:
- 'OAuth2 with JWT tokens for API endpoints'
- 'Do not log PII or raw ERP identifiers in logs'
- 'Secrets in environment variables; never commit them'
# Database and ORM patterns
database_and_orm_patterns:
- 'PostgreSQL with SQLAlchemy'
- 'Models under app/models'
- 'Alembic migrations for schema evolution'
# Testing & Linting Workflows
testing_and_linting_workflows:
- 'pytest with pytest-asyncio'
- 'pre-commit with black, isort, flake8'
- 'CI runs pytest --durations=10'
- 'Run unit and integration tests against a local PostgreSQL instance'
# Prohibited Actions and Anti-patterns for the AI
prohibited_actions_and_anti_patterns:
- 'Do not execute code from untrusted user input'
- 'Do not bypass authentication or secret handling'
- 'Do not write to ERP production data without explicit validation'
- 'Do not enable direct writes to ERP systems from the AI without a human gate'
Recommended Project Structure
project-root/
├── app/
│ ├── api/
│ │ └── endpoints.py
│ ├── models/
│ │ └── maintenance.py
│ ├── schemas/
│ │ └── pydantic_models.py
│ ├── core/
│ │ └── config.py
│ └── main.py
├── ai/
│ └── agents/
│ └── erp_maintenance_agent.py
├── data/
│ └── erp_logs/
├── migrations/
├── tests/
│ ├── unit/
│ └── integration/
├── requirements.txt
├── Dockerfile
├── docker-compose.yml
Core Engineering Principles
- Idempotence: every operation can be retried without side effects; ensure deterministic results for maintenance recommendations.
- Auditability: every AI action, decision reason, and data access is logged with user context.
- Separation of concerns: clear boundaries between data ingestion, AI reasoning, and action execution.
- Security by default: least privilege, encrypted data in transit, and secrets protected via environment-based configuration.
- Testability: emphasize unit and integration tests, with reliable mocking for ERP data sources.
- Observability: structured logging, metrics, and tracing across API, AI, and data layers.
Code Construction Rules
- Use typed Python (typing) with Pydantic models for input/output schemas.
- Store ERP logs in a dedicated data/erp-logs directory and read them via a dedicated ingestion service.
- Use SQLAlchemy ORM for PostgreSQL models; place models under app/models.
- All AI prompts must be wrapped with a safety layer and include a human-in-the-loop gate for critical actions.
- Follow RESTful API design for the FastAPI endpoints with clear status codes and messages.
- Provide deterministic prompts and avoid non-deterministic timing in AI responses.
- Respect data privacy by redacting sensitive ERP fields in logs used for AI reasoning.
- Documentation: maintain inline docstrings and a README.md describing the Cursor rules usage.
- Do not depend on non-approved libraries for ERP integration unless validated for security and licensing.
Security and Production Rules
- Encrypt data in transit (TLS) and at rest where applicable; use secure connections to PostgreSQL.
- Implement OAuth2 with JWT for API authentication; enforce role-based access control for maintenance actions.
- Never log complete ERP records; redact identifiers; implement data masking where needed.
- Use environment variables for secrets; rotate credentials regularly; avoid committing secret keys.
- Implement a human gate for critical actions like scheduling maintenance that affects production lines.
- Regularly review AI prompts and rules for safety and compliance in an industrial setting.
Testing Checklist
- Unit tests for data ingestion, ERP log parsing, and maintenance calculation logic.
- Integration tests for API endpoints, AI prompt generation, and task creation in the MES/ERP flow.
- End-to-end tests simulating ERP log streams and maintenance scheduling outputs.
- Linting and formatting checks in CI; ensure Black and isort pass.
- Security tests including secret exposure and access control verification.
Common Mistakes to Avoid
- Overloading AI prompts with raw ERP data; prefer structured prompts and data summaries.
- Relying on the AI to mutate production data without a human gate or approval workflow.
- Storing secrets in repository files or committing sample ERP data into code repos.
- Neglecting audit trails for maintenance actions and AI recommendations.
- Ignoring data masking requirements when handling ERP logs with PII or sensitive machine data.
Related implementation resources: AI Agent Use Case for Packaging Manufacturers Using Order Backlogs To Optimize Raw Paper Roll Slicing Sequences and Agentic AI for Real-Time Labor Productivity: Tracking, Crew Re-Allocation, and Operational Excellence.
FAQ
What is this Cursor Rules Template for?
This Cursor Rules Template provides a concrete set of Cursor AI rules to build an AI agent workflow that reads ERP logs from precision machining SMEs and plans preventative maintenance. It includes a real copyable .cursorrules block, a recommended project structure, and stack-specific guidance.
Which stack does this Cursor Rules Template cover?
The template targets Python 3.11+, FastAPI, PostgreSQL with SQLAlchemy, and a containerized deployment model—ideal for ERP log ingestion and AI-driven maintenance planning with Cursor AI.
How do I insert the copyable .cursorrules block into my project?
Copy the entire code block under Copyable .cursorrules Configuration and paste it into a new file named .cursorrules at your repository root. Ensure the project uses the same stack and adjust paths to your ERP data stores accordingly.
What security considerations are included?
Secrets must be stored in environment variables, API calls protected with OAuth2/JWT, and ERP identifiers redacted in logs. The rules emphasize guarded data access and auditability for maintenance actions.
How do I run and test the AI agent workflows locally?
Run with Docker Compose locally, set up a local PostgreSQL instance, and execute unit and integration tests with pytest. Validate AI prompts, task generation, and maintenance scheduling against a simulated ERP dataset.Overview
Direct answer: This Cursor Rules Template configures an AI Agent to ingest ERP logs from precision machining SMEs, reason about maintenance needs, and propose preventative maintenance plans. It targets a Python 3.11+ stack with FastAPI, PostgreSQL, and SQLAlchemy ORM to model maintenance data and actions, all orchestrated by Cursor AI.
The Cursor rules configuration furnishes guidelines the AI must follow to interpret ERP data, surface maintenance decisions with auditability, and keep production-safe AI operations. It is designed to be copy-pasted into a project root as a starting point for a production-ready workflow.
When to Use These Cursor Rules
- You have ERP logs (machine telemetry, preventive maintenance history, spare parts usage) and want AI-generated maintenance recommendations.
- You need deterministic AI behavior for scheduling work orders and aligning with inventory in an SME manufacturing environment.
- You require clear boundaries between data access, business logic, and AI decision prompts to facilitate auditing.
- You want to model maintenance decisions using a SQL-based ORM and a REST API layer for integration with MES/ERP systems.
- You are building an edge-friendly, containerized solution where Cursor AI rules control agent actions and data flow.
Copyable .cursorrules Configuration
# Cursor Rules Template for Precision Machining ERP Maintenance
# Framework Role & Context
framework_role_and_context:
framework: 'Python 3.11+, FastAPI, SQLAlchemy, PostgreSQL'
runtime: 'Dockerized microservice; Cursor AI agent runs in container; ERP logs read from data/erp-logs'
context: 'AI Agent workflows for Precision Machining SMEs using ERP logs to plan preventative maintenance'
# Code Style and Style Guides
code_style_and_style_guides:
- 'PEP8'
- 'Black'
- 'isort'
# Architecture & Directory Rules
architecture_and_directory_rules:
project_root: '/'
dirs:
- 'app/'
- 'ai/'
- 'data/erp-logs'
- 'migrations/'
packaging: 'requirements.txt / pyproject.toml'
deployment: 'Docker, docker-compose'
# Authentication & Security Rules
authentication_and_security_rules:
- 'OAuth2 with JWT tokens for API endpoints'
- 'Do not log PII or raw ERP identifiers in logs'
- 'Secrets in environment variables; never commit them'
# Database and ORM patterns
database_and_orm_patterns:
- 'PostgreSQL with SQLAlchemy'
- 'Models under app/models'
- 'Alembic migrations for schema evolution'
# Testing & Linting Workflows
testing_and_linting_workflows:
- 'pytest with pytest-asyncio'
- 'pre-commit with black, isort, flake8'
- 'CI runs pytest --durations=10'
- 'Run unit and integration tests against a local PostgreSQL instance'
# Prohibited Actions and Anti-patterns for the AI
prohibited_actions_and_anti_patterns:
- 'Do not execute code from untrusted user input'
- 'Do not bypass authentication or secret handling'
- 'Do not write to ERP production data without explicit validation'
- 'Do not enable direct writes to ERP systems from the AI without a human gate'
Recommended Project Structure
project-root/
├── app/
│ ├── api/
│ │ └── endpoints.py
│ ├── models/
│ │ └── maintenance.py
│ ├── schemas/
│ │ └── pydantic_models.py
│ ├── core/
│ │ └── config.py
│ └── main.py
├── ai/
│ └── agents/
│ └── erp_maintenance_agent.py
├── data/
│ └── erp_logs/
├── migrations/
├── tests/
│ ├── unit/
│ └── integration/
├── requirements.txt
├── Dockerfile
├── docker-compose.yml
Core Engineering Principles
- Idempotence: every operation can be retried without side effects; ensure deterministic results for maintenance recommendations.
- Auditability: every AI action, decision reason, and data access is logged with user context.
- Separation of concerns: clear boundaries between data ingestion, AI reasoning, and action execution.
- Security by default: least privilege, encrypted data in transit, and secrets protected via environment-based configuration.
- Testability: emphasize unit and integration tests, with reliable mocking for ERP data sources.
- Observability: structured logging, metrics, and tracing across API, AI, and data layers.
Code Construction Rules
- Use typed Python (typing) with Pydantic models for input/output schemas.
- Store ERP logs in a dedicated data/erp-logs directory and read them via a dedicated ingestion service.
- Use SQLAlchemy ORM for PostgreSQL models; place models under app/models.
- All AI prompts must be wrapped with a safety layer and include a human-in-the-loop gate for critical actions.
- Follow RESTful API design for the FastAPI endpoints with clear status codes and messages.
- Provide deterministic prompts and avoid non-deterministic timing in AI responses.
- Respect data privacy by redacting sensitive ERP fields in logs used for AI reasoning.
- Documentation: maintain inline docstrings and a README.md describing the Cursor rules usage.
- Do not depend on non-approved libraries for ERP integration unless validated for security and licensing.
Security and Production Rules
- Encrypt data in transit (TLS) and at rest where applicable; use secure connections to PostgreSQL.
- Implement OAuth2 with JWT for API authentication; enforce role-based access control for maintenance actions.
- Never log complete ERP records; redact identifiers; implement data masking where needed.
- Use environment variables for secrets; rotate credentials regularly; avoid committing secret keys.
- Implement a human gate for critical actions like scheduling maintenance that affects production lines.
- Regularly review AI prompts and rules for safety and compliance in an industrial setting.
Testing Checklist
- Unit tests for data ingestion, ERP log parsing, and maintenance calculation logic.
- Integration tests for API endpoints, AI prompt generation, and task creation in the MES/ERP flow.
- End-to-end tests simulating ERP log streams and maintenance scheduling outputs.
- Linting and formatting checks in CI; ensure Black and isort pass.
- Security tests including secret exposure and access control verification.
Common Mistakes to Avoid
- Overloading AI prompts with raw ERP data; prefer structured prompts and data summaries.
- Relying on the AI to mutate production data without a human gate or approval workflow.
- Storing secrets in repository files or committing sample ERP data into code repos.
- Neglecting audit trails for maintenance actions and AI recommendations.
- Ignoring data masking requirements when handling ERP logs with PII or sensitive machine data.
Related implementation resources: AI Agent Use Case for Packaging Manufacturers Using Order Backlogs To Optimize Raw Paper Roll Slicing Sequences and Agentic AI for Real-Time Labor Productivity: Tracking, Crew Re-Allocation, and Operational Excellence.
FAQ
What is this Cursor Rules Template for?
This Cursor Rules Template provides a concrete set of Cursor AI rules to build an AI agent workflow that reads ERP logs from precision machining SMEs and plans preventative maintenance. It includes a real copyable .cursorrules block, a recommended project structure, and stack-specific guidance.
Which stack does this Cursor Rules Template cover?
The template targets Python 3.11+, FastAPI, PostgreSQL with SQLAlchemy, and a containerized deployment model—ideal for ERP log ingestion and AI-driven maintenance planning with Cursor AI.
How do I insert the copyable .cursorrules block into my project?
Copy the entire code block under Copyable .cursorrules Configuration and paste it into a new file named .cursorrules at your repository root. Ensure the project uses the same stack and adjust paths to your ERP data stores accordingly.
What security considerations are included?
Secrets must be stored in environment variables, API calls protected with OAuth2/JWT, and ERP identifiers redacted in logs. The rules emphasize guarded data access and auditability for maintenance actions.
How do I run and test the AI agent workflows locally?
Run with Docker Compose locally, set up a local PostgreSQL instance, and execute unit and integration tests with pytest. Validate AI prompts, task generation, and maintenance scheduling against a simulated ERP dataset.