agentleFS
mmccallammccalla/coding-agent-skill-library/skills/prompt-chaining/SKILL.md

prompt-chaining

Skill4 starsChanged 5 months agoApache-2.0View on GitHub

Use when implementing or refactoring multi-step LLM workflows where outputs from one step feed later steps; especially useful for extraction, normalisation, generation, code refinement, and report synthesis.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 6

    Distinctive

    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 this skill when a single prompt or function is overloaded with multiple responsibilities.

    line 10
  2. Distinctive:

    Do not use it for a trivial one-step task.

    line 12
  3. Distinctive:

    Use JSON, XML, Pydantic, Zod or another schema mechanism for hand-offs.

    line 22
  4. Distinctive:

    Prefer pure functions for deterministic pre/post-processing.

    line 29
  5. Distinctive:

    Keep LLM prompts single-purpose.

    line 30
  6. Distinctive:

    Use a named pipeline object or graph rather than ad hoc nested calls.

    line 31

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “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
SKILL.md

Prompt Chaining

When to use

Use this skill when a single prompt or function is overloaded with multiple responsibilities. Apply it when the task has distinct stages, when intermediate outputs should be inspected, or when reliability depends on passing structured data between steps.

Do not use it for a trivial one-step task.

Objective

Decompose overloaded prompts into validated, single-purpose stages with testable hand-offs.

Procedure

  1. Identify each logically independent transformation.
  2. Define a narrow contract for each step: input schema, output schema, success criteria and error case.
  3. Use JSON, XML, Pydantic, Zod or another schema mechanism for hand-offs.
  4. Validate each intermediate output before passing it to the next step.
  5. Make every step independently testable.
  6. Persist or log intermediate artefacts where debugging or auditability matters.

Coding guidance

  • Prefer pure functions for deterministic pre/post-processing.
  • Keep LLM prompts single-purpose.
  • Use a named pipeline object or graph rather than ad hoc nested calls.
  • Fail fast on malformed intermediate outputs.
  • Include unit tests for every stage and an integration test for the whole chain.

References

Verification

  • Pipeline stages are named and documented.
  • Each stage has a clear input/output contract.
  • Structured output validation exists between stages.
  • Tests cover at least one happy path and one malformed intermediate output.
  • Logging makes it possible to identify which stage failed.

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.