CNC Dashboard Cursor Rules Template for AI-Driven Downtime, Tool Wear, and Bottlenecks
Cursor Rules Template for building AI dashboards in CNC workshops to analyze downtime, tool wear, and bottlenecks using Cursor AI.
Target User
Senior CNC engineers, data scientists, and backend/frontend engineers building AI-powered CNC dashboards.
Use Cases
- Downtime analytics for CNC machines
- Tool wear monitoring
- Bottleneck identification in production lines
- Maintenance scheduling optimization
- Real-time KPI dashboards
Markdown Template
CNC Dashboard Cursor Rules Template for AI-Driven Downtime, Tool Wear, and Bottlenecks
Overview
Cursor rules configuration enables Cursor AI to generate AI-assisted dashboards for CNC workshops, focusing on downtime, tool wear, and production bottlenecks. This template provides a concrete, copyable configuration tailored to a Python FastAPI + PostgreSQL stack with a React frontend.
Direct answer
By applying this Cursor rules template, you enable Cursor AI to orchestrate dashboards that surface actionable insights about machine uptime, wear trends, and line throughput, while enforcing safe AI behavior and reproducible results.
When to Use These Cursor Rules
- When you need automated downtime analytics across CNC machines and shifts.
- When tool wear trends must be monitored to schedule tool changes proactively.
- When bottlenecks in milling, turning, or inspection stages impact cycle times.
- When you require a testable, Git-friendly configuration for dashboard generation.
- When you want to enforce strict security, validation, and deployment hygiene.
Copyable .cursorrules Configuration
# Cursor Rules Template for CNC Dashboard
# Stack: Python FastAPI backend, PostgreSQL, SQLAlchemy, Alembic, React frontend
Framework Role & Context:
- You are Cursor AI configured to author safe, idempotent, and testable rules for AI-assisted dashboards in CNC environments.
- You know the CNC domain, including downtime metrics, tool wear indicators, and production bottlenecks.
Code Style and Style Guides:
- Python: PEP8, type hints, docstrings, black formatting, isort for imports.
- Frontend: React with ESLint + Prettier; avoid inline styles; accessible components.
Architecture & Directory Rules:
- Monorepo with backend/ and frontend/ only.
- Backend uses FastAPI, SQLAlchemy, Alembic; Frontend uses React.
- All configuration sourced from environment variables; secrets via Vault or CI secret manager.
Authentication & Security Rules:
- JWTs with short TTL; refresh tokens; OAuth2 where feasible.
- All endpoints authenticated; roles grant least privilege.
- No secrets in code or Git; use env vars and secret stores.
Database and ORM patterns:
- PostgreSQL; SQLAlchemy ORM with typed models; use Alembic migrations.
- Parameterized queries; avoid string concatenation for SQL; use ORM filters.
- Time-series indexes on downtime, cycle time, tool wear for fast analytics.
Testing & Linting Workflows:
- Backend: pytest, httpx for API tests; coverage >= 80%; CI runs on PRs.
- Frontend: Jest + React Testing Library; end-to-end tests with Playwright if possible.
- Linting: mypy for type checks; flake8; Black formatting.
Prohibited Actions and Anti-patterns for the AI:
- Do not generate code that bypasses authentication or bypasses the database constraints.
- Do not use dynamic SQL without parameterization; do not rely on implicit casts.
- Do not expose raw database credentials; do not perform admin operations via AI-generated code.
# End of Cursor Rules Template for CNC Dashboard
Recommended Project Structure
backend/
├── app/
│ ├── api/
│ │ ├── routes/
│ │ │ └── dashboard.py
│ │ └── __init__.py
│ ├── core/
│ │ └── config.py
│ ├── models/
│ │ └── sensorMetrics.py
│ ├── schemas/
│ │ └── dashboard.py
│ ├── db/
│ │ ├── base.py
│ │ └── session.py
│ └── main.py
├── tests/
│ ├── test_api.py
│ └── conftest.py
├── alembic/
│ └── env.py
frontend/
├── src/
│ ├── App.jsx
│ ├── index.jsx
│ ├── components/
│ │ └── Dashboard.jsx
│ └── hooks/
└── package.json
Core Engineering Principles
- Design for verifiability: dashboards should be deterministic and testable.
- Data integrity first: enforce schema validation, migrations, and type safety.
- Security by default: authenticated endpoints, least privilege, and secret management.
- Observability: structured logs, metrics, and tracing for AI-assisted rendering.
- Maintainable AI: rules that enforce safe outputs, auditability, and reproducibility.
Code Construction Rules
- Use typed models for input/output; validate all payloads in FastAPI with pydantic.
- All SQL interactions must be parameterized; avoid raw string interpolation.
- Frontend components must be small, reusable, and accessible; use PropTypes or TypeScript.
- Dashboards should be driven by declarative configuration, not hard-coded queries.
- Embrace versioned API contracts; add tests for breaking changes.
- Do not hard-code secrets; use environment variables and secret management.
Security and Production Rules
- Enable TLS in all environments; enforce HSTS.
- Rotate JWT signing keys; implement short-lived tokens with refresh tokens.
- Use parameterized queries and least-privilege database roles.
- Audit access to CNC sensor data; remove debug endpoints in production.
- Implement rate limiting on dashboard APIs; guard against injection attacks.
Testing Checklist
- Unit tests for API endpoints with mocked DB calls.
- Integration tests for dashboard data aggregation using a test PostgreSQL instance.
- End-to-end tests for the UI rendering and data flows.
- Lint, type checks, and pre-commit hooks in CI.
Common Mistakes to Avoid
- Ignoring time-series indexing; failing to index downtime and cycle time fields.
- Skipping migrations; migrating schema in production without review.
- Exposing raw sensor data to clients without aggregation or privacy controls.
- Using brittle string-based queries instead of ORM with parameterization.
Related implementation resources: AI Agent Use Case for Freight Terminals Using Cargo Volume Trends To Automate Forklift Fleet Allocation Across Shifts and Explicit rules for secrets management in AI tools: production-grade workflows and skills.
FAQ
What is a Cursor Rules Template for CNC dashboards?
A Cursor Rules Template standardizes how Cursor AI configures AI-assisted CNC dashboards with uptime, wear, and bottleneck analytics. It provides a reusable, copyable configuration and stack-specific guidance to accelerate safe AI-enabled development.
Which stack is targeted by this template?
This template targets a Python FastAPI backend with PostgreSQL, SQLAlchemy, Alembic, and a React frontend. It includes production-ready patterns for data modeling, API design, and UI data presentation in CNC analytics.
How do I customize downtime metrics?
Customize SQL queries, aggregates, and data sources for downtime by adding machine identifiers, shift slots, and downtime events. Validate queries, ensure proper indexing, and keep the Cursor rules block in sync with data sources.
What security practices are enforced?
Use JWT-based authentication with short-lived tokens, rotate keys, avoid embedding secrets in code, enforce TLS, and restrict access to sensitive dashboards with role-based permissions.
How do I test the Cursor rules?
Run unit tests for backend data helpers, integration tests for API endpoints, and UI tests for the dashboard. Use a test database and seed it with representative downtime, wear, and bottleneck data to validate visuals.
What is the recommended project structure?
Keep backend and frontend in separate directories with clear API boundaries, migrations, and tests. The template’s tree is designed to be copy-pasted into a starter repo to accelerate onboarding.
Can I adapt the template to a different CNC stack?
Yes. Replace backend/ stack with your preferred backend language and ORM, adjust data models for your sensors, and keep the Cursor rules format intact for safe, auditable AI-assisted dashboards.Overview
Cursor rules configuration enables Cursor AI to generate AI-assisted dashboards for CNC workshops, focusing on downtime, tool wear, and production bottlenecks. This template provides a concrete, copyable configuration tailored to a Python FastAPI + PostgreSQL stack with a React frontend.
Direct answer
By applying this Cursor rules template, you enable Cursor AI to orchestrate dashboards that surface actionable insights about machine uptime, wear trends, and line throughput, while enforcing safe AI behavior and reproducible results.
When to Use These Cursor Rules
- When you need automated downtime analytics across CNC machines and shifts.
- When tool wear trends must be monitored to schedule tool changes proactively.
- When bottlenecks in milling, turning, or inspection stages impact cycle times.
- When you require a testable, Git-friendly configuration for dashboard generation.
- When you want to enforce strict security, validation, and deployment hygiene.
Copyable .cursorrules Configuration
# Cursor Rules Template for CNC Dashboard
# Stack: Python FastAPI backend, PostgreSQL, SQLAlchemy, Alembic, React frontend
Framework Role & Context:
- You are Cursor AI configured to author safe, idempotent, and testable rules for AI-assisted dashboards in CNC environments.
- You know the CNC domain, including downtime metrics, tool wear indicators, and production bottlenecks.
Code Style and Style Guides:
- Python: PEP8, type hints, docstrings, black formatting, isort for imports.
- Frontend: React with ESLint + Prettier; avoid inline styles; accessible components.
Architecture & Directory Rules:
- Monorepo with backend/ and frontend/ only.
- Backend uses FastAPI, SQLAlchemy, Alembic; Frontend uses React.
- All configuration sourced from environment variables; secrets via Vault or CI secret manager.
Authentication & Security Rules:
- JWTs with short TTL; refresh tokens; OAuth2 where feasible.
- All endpoints authenticated; roles grant least privilege.
- No secrets in code or Git; use env vars and secret stores.
Database and ORM patterns:
- PostgreSQL; SQLAlchemy ORM with typed models; use Alembic migrations.
- Parameterized queries; avoid string concatenation for SQL; use ORM filters.
- Time-series indexes on downtime, cycle time, tool wear for fast analytics.
Testing & Linting Workflows:
- Backend: pytest, httpx for API tests; coverage >= 80%; CI runs on PRs.
- Frontend: Jest + React Testing Library; end-to-end tests with Playwright if possible.
- Linting: mypy for type checks; flake8; Black formatting.
Prohibited Actions and Anti-patterns for the AI:
- Do not generate code that bypasses authentication or bypasses the database constraints.
- Do not use dynamic SQL without parameterization; do not rely on implicit casts.
- Do not expose raw database credentials; do not perform admin operations via AI-generated code.
# End of Cursor Rules Template for CNC Dashboard
Recommended Project Structure
backend/
├── app/
│ ├── api/
│ │ ├── routes/
│ │ │ └── dashboard.py
│ │ └── __init__.py
│ ├── core/
│ │ └── config.py
│ ├── models/
│ │ └── sensorMetrics.py
│ ├── schemas/
│ │ └── dashboard.py
│ ├── db/
│ │ ├── base.py
│ │ └── session.py
│ └── main.py
├── tests/
│ ├── test_api.py
│ └── conftest.py
├── alembic/
│ └── env.py
frontend/
├── src/
│ ├── App.jsx
│ ├── index.jsx
│ ├── components/
│ │ └── Dashboard.jsx
│ └── hooks/
└── package.json
Core Engineering Principles
- Design for verifiability: dashboards should be deterministic and testable.
- Data integrity first: enforce schema validation, migrations, and type safety.
- Security by default: authenticated endpoints, least privilege, and secret management.
- Observability: structured logs, metrics, and tracing for AI-assisted rendering.
- Maintainable AI: rules that enforce safe outputs, auditability, and reproducibility.
Code Construction Rules
- Use typed models for input/output; validate all payloads in FastAPI with pydantic.
- All SQL interactions must be parameterized; avoid raw string interpolation.
- Frontend components must be small, reusable, and accessible; use PropTypes or TypeScript.
- Dashboards should be driven by declarative configuration, not hard-coded queries.
- Embrace versioned API contracts; add tests for breaking changes.
- Do not hard-code secrets; use environment variables and secret management.
Security and Production Rules
- Enable TLS in all environments; enforce HSTS.
- Rotate JWT signing keys; implement short-lived tokens with refresh tokens.
- Use parameterized queries and least-privilege database roles.
- Audit access to CNC sensor data; remove debug endpoints in production.
- Implement rate limiting on dashboard APIs; guard against injection attacks.
Testing Checklist
- Unit tests for API endpoints with mocked DB calls.
- Integration tests for dashboard data aggregation using a test PostgreSQL instance.
- End-to-end tests for the UI rendering and data flows.
- Lint, type checks, and pre-commit hooks in CI.
Common Mistakes to Avoid
- Ignoring time-series indexing; failing to index downtime and cycle time fields.
- Skipping migrations; migrating schema in production without review.
- Exposing raw sensor data to clients without aggregation or privacy controls.
- Using brittle string-based queries instead of ORM with parameterization.
Related implementation resources: AI Agent Use Case for Freight Terminals Using Cargo Volume Trends To Automate Forklift Fleet Allocation Across Shifts and Explicit rules for secrets management in AI tools: production-grade workflows and skills.
FAQ
What is a Cursor Rules Template for CNC dashboards?
A Cursor Rules Template standardizes how Cursor AI configures AI-assisted CNC dashboards with uptime, wear, and bottleneck analytics. It provides a reusable, copyable configuration and stack-specific guidance to accelerate safe AI-enabled development.
Which stack is targeted by this template?
This template targets a Python FastAPI backend with PostgreSQL, SQLAlchemy, Alembic, and a React frontend. It includes production-ready patterns for data modeling, API design, and UI data presentation in CNC analytics.
How do I customize downtime metrics?
Customize SQL queries, aggregates, and data sources for downtime by adding machine identifiers, shift slots, and downtime events. Validate queries, ensure proper indexing, and keep the Cursor rules block in sync with data sources.
What security practices are enforced?
Use JWT-based authentication with short-lived tokens, rotate keys, avoid embedding secrets in code, enforce TLS, and restrict access to sensitive dashboards with role-based permissions.
How do I test the Cursor rules?
Run unit tests for backend data helpers, integration tests for API endpoints, and UI tests for the dashboard. Use a test database and seed it with representative downtime, wear, and bottleneck data to validate visuals.
What is the recommended project structure?
Keep backend and frontend in separate directories with clear API boundaries, migrations, and tests. The template’s tree is designed to be copy-pasted into a starter repo to accelerate onboarding.
Can I adapt the template to a different CNC stack?
Yes. Replace backend/ stack with your preferred backend language and ORM, adjust data models for your sensors, and keep the Cursor rules format intact for safe, auditable AI-assisted dashboards.