Summary
Create automated CI/CD workflows that validate each change through type checks, tests, and reproducible builds. A reliable CI pipeline ensures safe deployments and reduces production regressions.
Objectives
Principles
1. CI must prove correctness before merging.
2. Pipelines should be deterministic and documented.
3. Deployments should be small, observable, and reversible.
4. CI output should make debugging straightforward.
Implementation Pattern
Step 1: Outline pipeline stages.
Include static analysis, type checking, unit tests, integration tests, artifact generation, and deployment steps.
Step 2: Scaffold workflow files for GitHub Actions, GitLab CI, or another system.
Use shared templates for linting, testing, and building.
Step 3: Make stages parallel and incremental where possible to reduce run times.
Step 4: Add deployment safety features.
Use health checks, canary releases, and approval gates when needed.
Step 5: Validate workflows using local runners or Cursor’s execution capabilities.
Bug Prevention Examples
Anti-Pattern (Before)
Developers run ad-hoc scripts locally and manually deploy code, resulting in inconsistent builds and untested changes reaching production.
Recommended Pattern (After)
A standardized workflow where pull requests trigger linting, typing, and tests, while merges create artifacts and deploy safely to staging or production.
Best Practices
Cursor Prompts
"Create a CI workflow with linting, typing, tests, and safe deployment steps."
"Add a canary deployment strategy with rollback support."
"Set up caching and parallel execution to optimize CI time."
Notes
CI/CD is essential to maintaining reliability and enabling rapid iteration across teams.