# Cache Identical Fork Prefix Construction

> Build forked conversation prefixes that stay identical across turns so prompt caching keeps working.

- **Type:** Skill
- **Install:** `agentstack add skill-ychampion-cskill-agents-cache-identical-fork-prefix-construction`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [ychampion](https://agentstack.voostack.com/s/ychampion)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [ychampion](https://github.com/ychampion)
- **Source:** https://github.com/ychampion/cskill-agents/tree/main/agents/claude-code/skills/cache-identical-fork-prefix-construction
- **Website:** https://x.com/YashasGunderia/status/2039990540016693692?s=20

## Install

```sh
agentstack add skill-ychampion-cskill-agents-cache-identical-fork-prefix-construction
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# SKILL: Cache Identical Fork Prefix Construction
**Domain:** caching
**Trigger:** Use this when a forked agent must reuse the parent prompt cache and needs byte-identical prefixes for each invocation.
**Source Pattern:** Distilled from reviewed subagent orchestration, isolation, and lifecycle implementations.

## Core Method
Duplicate the parent assistant message wholesale, then generate a single user message containing standardized tool_result placeholders (all with the same text) followed by the directive text. Keeping every byte of the assistant message and placeholder deterministic ensures that identical tool_use sequences map to the same cache key. Build a child-specific directive message by wrapping it in `` and appending fork directive prefix before the per-worker instructions.

## Key Rules
- Never mutate the cached assistant message; copy it to a new object and only append the uniform tool_result blocks and directive text afterward.
- Use identical placeholder text (`Fork started — processing in background`) for every tool_result so the child prefix byte stream stays constant across runs.
- Append the directive text as the final block after the placeholders, ensuring fork children encode their own instructions without altering earlier bytes.
- Provide the directive in the same build child message helper so the cached prefix always ends with the same sentinel.

## Example Application
When the model triggers a fork from an inline agent, reuse this method to build the fork prompt so the fork shares the cache of the parent — future identical tasks reuse the same cached prefix and avoid redundant API calls.

## Anti-Patterns (What NOT to do)
- Do not recompute the assistant message or tool_result text differently per turn; any divergence breaks the cache key.
- Avoid embedding random IDs or timestamps inside the prefix; keep only stable verbatim text before the directive block.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [ychampion](https://github.com/ychampion)
- **Source:** [ychampion/cskill-agents](https://github.com/ychampion/cskill-agents)
- **License:** MIT
- **Homepage:** https://x.com/YashasGunderia/status/2039990540016693692?s=20

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-ychampion-cskill-agents-cache-identical-fork-prefix-construction
- Seller: https://agentstack.voostack.com/s/ychampion
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
