Home › GitHub Actions › GitHub Actions workflow rules

GitHub Actions workflow rules

Cursor rules for writing secure, fast GitHub Actions workflows: permissions, pinning, caching, and concurrency.

CursorGitHub Actions

How to use

Save this as .cursor/rules/github-actions.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/github-actions.mdcDownload  
---
description: GitHub Actions workflow conventions
globs: [".github/workflows/*.{yml,yaml}",".github/actions/**"]
alwaysApply: false
---

# GitHub Actions

- Set least-privilege `permissions:` at the workflow top (`contents: read`) and widen per job only where needed.
- Pin third-party actions to a full commit SHA with the version in a comment (`uses: actions/checkout@<sha> # v4.2.2`). First-party `actions/*` may use major tags only if the repo already does.
- Never interpolate untrusted input (`github.event.issue.title`, PR branch names, comment bodies) directly into `run:`. Pass it through `env:` and quote `"$VAR"`.
- Avoid `pull_request_target` with a checkout of the PR head. If it's unavoidable, don't run the PR's code with secrets.
- Cloud auth via OIDC (`id-token: write` + the provider's login action), not long-lived keys in secrets.
- Use built-in caching (`actions/setup-node` `cache: pnpm`, `setup-python` `cache: pip`) before writing custom `actions/cache` steps.
- Add `concurrency: { group: ${{ github.workflow }}-${{ github.ref }}, cancel-in-progress: true }` to PR workflows.
- Set `timeout-minutes` on every job. Use `matrix` for versions; `fail-fast: false` when results per entry matter.
- Reuse logic with reusable workflows (`workflow_call`) or composite actions instead of copy-paste.
- Path filters (`paths:`) to skip unrelated jobs in monorepos.

## Don't
- Don't echo secrets, or use `set -x` in steps that touch them.

## Done when
`actionlint` passes (and `zizmor .github/workflows` if installed).

More: all GitHub Actions rules · all Cursor rules

Related rules

GitHub Actions Copilot path instructions

Path-specific Copilot instructions for .github/workflows YAML: least privilege, pinned actions, and injection-safe steps.

GitHub CopilotGitHub Actions

Ansible Windsurf rules

Windsurf rules for Ansible playbooks and roles: FQCN modules, idempotency, check mode, vault secrets, and ansible-lint.

WindsurfAnsible

AWS CDK (TypeScript) CLAUDE.md

CLAUDE.md for AWS CDK v2 apps in TypeScript: constructs, least-privilege grants, snapshot tests, and safe deploys.

Claude Code (CLAUDE.md)AWS CDK

Docker & Compose AGENTS.md

AGENTS.md for containerized projects: lean multi-stage Dockerfiles, Docker Compose for local dev, and image security.

AGENTS.mdDocker

Dockerfile Copilot path instructions

Path-specific Copilot instructions for Dockerfiles and compose files: multi-stage builds, non-root, and pinned images.

GitHub CopilotDocker

Kubernetes & Helm CLAUDE.md

CLAUDE.md for Kubernetes manifests and Helm 3 charts: resources, probes, security context, and safe rollouts.

Claude Code (CLAUDE.md)Kubernetes / Helm

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.