Skip to main content

Claude/ChatGPT Prompt to Build a Reusable GitHub Actions Workflow

Reusable GitHub Actions workflow callable across repos: typed inputs, secrets, matrix strategy, caching, concurrency, and a composite action.

Vul de plaatshouders in

Edit the values, then copy your finished prompt.

Jouw Prompt
prompt.txt

                                

What this prompt does

This prompt makes the model act as a senior DevOps engineer and build a reusable GitHub Actions workflow, returning working YAML rather than pseudocode. Four placeholders tailor it: [purpose] (what the pipeline does), [toolchain] (the runtime and tooling), [matrix] (the dimensions to test across), and [secrets] (the secrets the workflow declares and consumes).

The structure works because it targets the real failure mode of CI: the same lint-test-build pipeline copy-pasted into every repo until one drifts and breaks silently. By asking for a workflow_call definition with typed inputs, a matrix across [matrix], correctly keyed caching, concurrency that cancels superseded runs, a factored-out composite action, and an example consumer in another repo, the prompt centralizes the pipeline so one fix lands everywhere. The cache-key emphasis matters because a bad key quietly serves stale builds. Declaring [secrets] in the workflow_call contract makes the interface explicit, so consumers know exactly what to pass, and pinning [toolchain] keeps the setup, cache, and build steps consistent with the runtime you actually ship on.

When to use it

  • You keep copy-pasting the same CI pipeline into every repo and want one reusable source.
  • You need a workflow_call definition with typed inputs, defaults, and declared [secrets].
  • You want a matrix across [matrix] with fail-fast tuned for fast feedback.
  • You need dependency and build caching keyed correctly for [toolchain].
  • You want concurrency control that cancels superseded runs on the same ref.
  • You need a composite action for steps repeated across jobs plus a consumer example.

Example output

Expect three separate code blocks: the reusable workflow YAML (a workflow_call with typed inputs, sensible defaults, and declared secrets, a matrix across [matrix], caching keyed for [toolchain], and concurrency that cancels superseded runs), the composite action YAML factoring out the repeated steps, and an example consumer workflow in a different repo that calls the reusable one. The whole thing reflects [purpose] so the jobs match what you actually run.

Pro tips

  • Get the cache keys right for [toolchain] — a bad key serves stale builds and sends you chasing ghosts for hours.
  • List [secrets] precisely so the workflow_call declares exactly what consumers must pass and nothing leaks implicitly.
  • Tune fail-fast on the [matrix] to your taste: on for fast feedback, off when you want full coverage of which combinations fail.
  • Keep [purpose] specific (e.g. lint + test + typecheck for Node apps) so the generated steps map to your real pipeline.
  • Test the consumer workflow in a second repo before rolling it out; that is where input and secret wiring mistakes surface.
  • Give typed inputs sensible defaults so most consumers can call the workflow with almost no configuration and override only when they need to.
  • Move any step repeated across matrix jobs into the composite action rather than duplicating it inline, so a single edit updates every job at once.

Frequently Asked Questions

Can this workflow be called from other repositories?
Yes, that is its purpose. It is built as a `workflow_call` definition with typed inputs and declared secrets, and the prompt also produces an example consumer workflow in a different repo so you can see exactly how to invoke it.
Does it handle caching correctly?
Deliverable three sets up dependency and build caching keyed to avoid stale hits for your `[toolchain]`. The prompt stresses key correctness because a poorly scoped key silently serves outdated builds, which is hard to diagnose later.
What does the composite action do?
It factors out the steps repeated across jobs into one reusable action, so you maintain that logic in a single place instead of duplicating it. The prompt returns the composite action YAML as its own code block.
Will it cancel old runs when I push again?
Yes. Deliverable four adds concurrency control that cancels superseded runs on the same ref, so a new push to a branch stops the now-outdated in-progress run instead of wasting CI minutes.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Meer in Git & GitHub Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support