github-actions
GitHub Actions best practices for writing and reviewing workflows. Use when creating or modifying .github/workflows/ files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
GitHub Actions best practices for writing and reviewing workflows. Use when creating or modifying .github/workflows/ files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
An example custom skill.
An example custom skill version for demonstration.
Reviews the work just done and updates CLAUDE.md, agent memories, and subagent MD files to reflect any new conventions, packages, resources, or patterns discovered. Run after completing any significant implementation task.
Plans and scaffolds Anthropic API endpoints as Terraform resources/data sources without a task management tool. TRIGGER when: user says "implement GitHub issues", references a range of GitHub issues to implement (e.g. "issues 52 to 57"), asks to parallelize implementation of multiple resources/data sources, or says "implement all [API name] APIs" or "work on a new API" (e.g. /v1/skills, /v1/environments). Generates GitHub issues and branches if they to not already exist — one per resource/data source — ready for sequential or parallel implementation.
Plans and scaffolds Anthropic API endpoints as Terraform resources/data sources for Vibe Kanban. TRIGGER when: user says "implement GitHub issues", references a range of GitHub issues to implement (e.g. "issues 52 to 57"), asks to parallelize implementation of multiple resources/data sources, or says "implement all [API name] APIs". Creates Vibe Kanban issues, workspaces, and fires parallel agents — one per resource/data source.
Updates the GitHub PR description for the current branch based on the work done in the current Claude session. Use after any meaningful change to a PR (feature, fix, refactor, docs). Invoked automatically when Claude stops if an open PR exists for the current branch. Also works inside Vibe Kanban worktrees (vk/* branches) by resolving the PR via the VK issue context.
| name | github-actions |
| description | GitHub Actions best practices for writing and reviewing workflows. Use when creating or modifying .github/workflows/ files. |
| model | sonnet |
Refer to the GitHub Actions workflow syntax guide to find details about how to implement certain actions in workflows or actions.
Every uses: reference must be pinned to a full commit SHA. Tags and branches are mutable and can be silently redirected (supply chain attack vector). Add the version tag as a trailing comment so humans know what version is in use.
# Bad — mutable tag
uses: hashicorp/setup-terraform@v3
# Good — immutable SHA + human-readable comment
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269ef032 # v3.1.2
This applies to all third-party actions including actions/ official actions.
Always set a zero-permission block at the workflow level to disable all permissions by default:
permissions: {}
Then set an explicit permissions: block on every job, granting only what that job needs:
contents: readcontents: writeid-token: writepull-requests: write, issues: writeNever leave a job without a permissions: block.
${{ }} expressions are expanded before the shell executes — no escaping occurs. Any attacker-controlled value in a run: step is an arbitrary code execution risk.
Never interpolate these directly in run: steps:
| Source | Variable |
|---|---|
| PR title | github.event.pull_request.title |
| PR body | github.event.pull_request.body |
| Issue title | github.event.issue.title |
| Comment body | github.event.comment.body |
| Branch name | github.event.pull_request.head.ref |
| Commit message | github.event.head_commit.message |
| Dispatch input | github.event.inputs.* |
# Bad — injection risk
- run: echo "PR: ${{ github.event.pull_request.title }}"
# Good — pass through env var
- run: echo "PR: $PR_TITLE"
env:
PR_TITLE: ${{ github.event.pull_request.title }}
Every job's first step must be step-security/harden-runner, SHA-pinned, with egress-policy: audit. This intercepts all outbound network calls and logs unexpected egress (e.g., a compromised action exfiltrating secrets).
steps:
- name: Harden runner
uses: step-security/harden-runner@<full-sha> # <version tag>
with:
egress-policy: audit
env: or with: — never interpolated directly into run: shell commands with ${{ secrets.FOO }} (log injection risk).# Bad — log injection risk
- run: curl -H "Authorization: ${{ secrets.API_KEY }}" https://example.com
# Good
- run: curl -H "Authorization: $API_KEY" https://example.com
env:
API_KEY: ${{ secrets.API_KEY }}
Jobs that use repository secrets must not be triggerable from fork pull requests. Fork PRs run with no access to secrets under a plain pull_request trigger — but this protection is bypassed by pull_request_target, which runs in the base branch context and exposes secrets.
pull_request_target for jobs that access secrets unless forked code is never checked out.push to a protected branch, workflow_dispatch, or a GitHub Environment with required reviewers.# Correct pattern for jobs needing secrets (e.g., acceptance tests)
on:
push:
branches: [main]
workflow_dispatch:
jobs:
acceptance-tests:
environment: production # requires manual approval from a maintainer
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
security.yml workflowThe project must have .github/workflows/security.yml with four jobs, all SHA-pinned, triggered on pull_request and merge_group:
| Job | Tool | What it checks |
|---|---|---|
actionlint | rhysd/actionlint | Syntax errors and hazardous patterns in workflow YAML |
poutine | Binary from GitHub releases | Supply-chain vulnerabilities (unpinned actions, script injections) |
semgrep | semgrep/semgrep-action | Anti-patterns including pull_request_target misuse |
checkov | bridgecrewio/checkov-action | Bad practices (write-all permissions, unsecure commands) |
.pre-commit-config.yaml must include hooks for all four tools: actionlint, poutine, semgrep, checkov.
tools/semgrep.yml — custom semgrep rules scoped to .github/. Add new workflow anti-pattern rules here.tools/.poutine.yml — skip list for known-safe unverified-creator actions. Uses PURL format pkg:githubactions/<owner>/<repo> (no SHA). When intentionally using an unverified-creator action, add it here with a comment explaining why it is trusted.Quality-gate Makefile targets must each have a corresponding CI job. Reference make <target> in CI steps rather than reimplementing the logic inline — this avoids drift between local and CI behavior.
Targets that must be covered: fmt, lint, test, testacc, generate, terraform-test.
The install target writes to a local path and does not need its own CI job, but is typically a prerequisite step.