agentleFS
ivangrynenkoivangrynenko/cursorrules/.cursor/rules/lagoon-yml-standards.mdc

cursorrules / rules

Cursor rule88 starsChanged 13 months agoMITView on GitHub

Standards for Lagoon configuration files and deployment workflows

The file

We split this lagoon-yml-standards.mdc into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use environment-specific configurations for different deployment targets

    line 41
  2. Distinctive:

    Use environment-specific routes and domains

    line 44
  3. Distinctive:

    Use wildcard domains for feature branch environments

    line 50
  4. Distinctive:

    Use conditional task execution based on environment

    line 55
  5. Distinctive:

    Use randomized cron schedules with 'M' and 'H' notation

    line 60
  6. Distinctive:

    Ensure cron jobs have proper error handling

    line 62
  7. Distinctive:

    Use descriptive names for cron jobs

    line 63

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
lagoon-yml-standards.mdc
---
description: Standards for Lagoon configuration files and deployment workflows
globs: .lagoon.yml, .lagoon.*.yml
---
# Lagoon Configuration Standards

Ensures proper configuration and best practices for Lagoon deployment files, focusing on environment configuration, routes, tasks, and deployment workflows.

<rule>
name: lagoon_yml_standards
description: Enforce standards for Lagoon configuration files
filters:
  - type: file_extension
    pattern: "\\.(yml|yaml)$"
  - type: file_name
    pattern: "^\\.lagoon(\\.\\w+)?\\.yml$"

actions:
  - type: enforce
    conditions:
      - pattern: "environments:\\s*[\\w-]+:\\s*routes:\\s*-\\s*\\w+:\\s*-[^:]+:\\s*tls-acme:\\s*true"
        message: "Ensure tls-acme is set to 'false' until DNS points to Lagoon to prevent certificate issuance failures"

      - pattern: "post-rollout:\\s*-\\s*run:\\s*command:\\s*drush(?!.*\\|\\|)"
        message: "Wrap Drush commands in proper error handling using '|| exit 1' to ensure deployment fails on command errors"

      - pattern: "pre-rollout:\\s*-\\s*run:\\s*command:\\s*(?!.*if)"
        message: "Add conditional checks for pre-rollout tasks to ensure they only run when necessary"

      - pattern: "cronjobs:\\s*-\\s*name:[^\\n]*\\n\\s*schedule:\\s*'\\*\\s*\\*'"
        message: "Use 'M' or 'H' notation for randomized cron scheduling to prevent server load spikes"
        
      - pattern: "routes:\\s*-\\s*\\w+:\\s*-[^:]+:\\s*(?!.*redirects:)"
        message: "Consider configuring redirects for routes to handle legacy URLs or domain migrations"

  - type: suggest
    message: |
      ## Lagoon Configuration Best Practices:
      
      ### Environment Configuration
      - Use environment-specific configurations for different deployment targets
      - Define environment types for proper resource allocation
      - Configure environment variables specific to each environment
      - Use environment-specific routes and domains
      
      ### Routes Configuration
      - Configure routes with appropriate SSL settings
      - Set up redirects for legacy URLs
      - Configure proper insecure traffic handling (Allow or Redirect)
      - Use wildcard domains for feature branch environments
      
      ### Tasks Configuration
      - Implement proper pre-rollout tasks with error handling
      - Configure post-rollout tasks with appropriate conditions
      - Use conditional task execution based on environment
      - Include database sync in PR environments
      - Implement proper backup strategies before major changes
      
      ### Cron Configuration
      - Use randomized cron schedules with 'M' and 'H' notation
      - Set appropriate frequency for different tasks
      - Ensure cron jobs have proper error handling
      - Use descriptive names for cron jobs
      
      ### Example Configuration:
      ```yaml
      environments:
        main:
          cronjobs:
            - name: drush-cron
              schedule: '*/15 * * * *'
              command: drush cron
              service: cli
          routes:
            - nginx:
              - example.com:
                  tls-acme: true
                  insecure: Redirect
                  redirects:
                    - www.example.com
          tasks:
            pre-rollout:
              - run:
                  name: Drush pre-update
                  command: |
                    if drush status --fields=bootstrap | grep -q "Successful"; then
                      drush state:set system.maintenance_mode 1 -y
                      drush cr
                    fi
                  service: cli
            post-rollout:
              - run:
                  name: Drush post-update
                  command: |
                    drush updb -y || exit 1
                    drush cr
                    drush state:set system.maintenance_mode 0 -y
                  service: cli
      ```

  - type: validate
    conditions:
      - pattern: "environments:\\s*[\\w-]+:\\s*types:\\s*[^\\n]*"
        message: "Define environment types for proper resource allocation and environment-specific configuration"

      - pattern: "tasks:\\s*(pre|post)-rollout:"
        message: "Include both pre and post rollout tasks for robust deployments and proper application state management"

      - pattern: "routes:\\s*-\\s*\\w+:\\s*-[^:]+:\\s*insecure:\\s*(Allow|Redirect)"
        message: "Configure proper insecure traffic handling to ensure secure access to your application"
        
      - pattern: "(?!.*backup-strategy:)"
        message: "Consider implementing a backup strategy for critical environments to prevent data loss"
        
      - pattern: "cronjobs:\\s*-\\s*name:[^\\n]*\\n\\s*schedule:[^\\n]*\\n\\s*(?!.*service:)"
        message: "Specify the service for cron jobs to ensure they run in the correct container"

metadata:
  priority: critical
  version: 1.1
</rule> 

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.