avoid-duplicate-system-messages

avoid-duplicate-system-messages is a skill for Claude Code, Codex from alivirgo/Major-AI-Skills. It costs 25 tokens per session (1,234 once invoked), scanned A, original, MIT.

A method for combining repeated system instructions into one fixed header at the start of an AI conversation. System instructions are rules that guide the model, while prompt caching reuses an unchanged conversation prefix.

In plain words
What is it for?
It is for designing multi-agent conversations with one stable set of shared rules, especially when tools or agents would otherwise add the same instructions repeatedly.
Why use it?
Repeated or scattered instructions can prevent that prefix from being cached and make the same text get sent again on every turn. It helps reduce unnecessary input text and related costs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument; mentions Codex.

Part of the major-ai-skills plugin — 147 skills, 7 plugins shipped together

Good fit It is for designing multi-agent conversations with one stable set of shared rules, especially when tools or agents would otherwise add the same instructions repeatedly.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/alivirgo/major-ai-skills/avoid-duplicate-system-messages
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add alivirgo/Major-AI-Skills --skill avoid-duplicate-system-messages
Clone the repo
git clone --depth 1 https://github.com/alivirgo/Major-AI-Skills

Made for: Claude Code, Codex.

Or install major-ai-skills, the plugin that ships this one along with the rest of its 147 skills, 7 plugins.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for avoid-duplicate-system-messages

README.md
[![agentmods](https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/avoid-duplicate-system-messages/github.svg)](https://agentmods.dev/skills/alivirgo/major-ai-skills/avoid-duplicate-system-messages)
Your own site
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/avoid-duplicate-system-messages"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/avoid-duplicate-system-messages/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for avoid-duplicate-system-messages

Your own site · 80×15
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/avoid-duplicate-system-messages"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/avoid-duplicate-system-messages.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,234 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.01234
Opus 5 $0.00013 $0.00617
Sonnet 5 $0.00005 $0.00247
Haiku 4.5 $0.00003 $0.00123

Measured yesterday against content hash 1f4622d89800, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

avoid-duplicate-system-messages scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/avoid-duplicate-system-messages/SKILL.md · 121 lines

How it starts

The opening of the file, as written. The whole thing — 121 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Deduplicate System Messages (Prompt Cache Prefix Consolidation)

Overview

Many multi-agent frameworks inject fresh role: "system" messages or duplicate guideline blocks into the middle of conversation histories (e.g., re-injecting system rules after every tool execution).

Scattering system messages throughout the message array causes two severe issues:

  1. Breaks Prompt Caching: Modern LLM caching engines (Anthropic Prompt Caching, OpenAI Prefix Caching) require a static, uninterrupted prefix. Injecting dynamic system messages invalidates the cache on every turn.
  2. Input Token Inflation: Re-sending 1,500 tokens of system instructions on every turn across 40 turns burns 60,000 redundant input tokens.

The System Prompt Consolidation Protocol enforces a single, canonical, immutable system header at Turn 0, ensuring maximum prompt cache hit rates (90% discount) and zero redundant token spend.


Fragmented System Injection vs. Consolidated Prefix Cache

┌─────────────────────────────────────────────────────────────┐
│                 Prompt Cache Invalidation                   │
│                                                             │
│  Fragmented System Injections (Anti-Pattern):               │
│  • Turn 0: System Message (1,200 tokens)                    │
│  • Turn 1: User Request                                     │
│  • Turn 2: System Message ("Remember to be concise!")       │
│    ↳ INVALIDATES PROMPT CACHE AT TURN 2! Full re-bill!      │
│  • Turn 3: System Message ("Follow tool rules!")            │
│    ↳ INVALIDATES PROMPT CACHE AT TURN 3!                    │
│                                                             │
│  Consolidated Single-Prefix Architecture (Cached):          │
│  • Turn 0: Single Static Consolidated System Header         │
│    ↳ CACHE_CONTROL: EPHEMERAL (Locks in 90% discount)       │
│  • Turn 1..50: Dynamic User & Assistant Turns ONLY          │
│    ↳ 100% Cache Hit Rate across entire 50-turn session!     │
└─────────────────────────────────────────────────────────────┘

Read the full file on GitHub · 121 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · -15 tokens per session 1f4622d89800
  2. 6d ago First seen · 121 lines · 40 tokens per session scan A ace4ac2a537b

Subscribe to this mod's changes

avoid-duplicate-system-messages is a skill published in the GitHub repository alivirgo/Major-AI-Skills (1 stars, last pushed today), licensed MIT. It adds 25 tokens to every session and 1,234 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

ai-wrapper-product-v2

AI Wrapper Product workflow skill. Use this skill when the user needs Expert in building products that wrap AI APIs (OpenAI, Anthropic, and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.

diegosouzapw/awesome-omni-skills · 55 tokens

ai-engineering-toolkit

AI Engineering Toolkit workflow skill. Use this skill when the user needs 6 production-ready AI engineering workflows: prompt evaluation (8-dimension scoring), context budget planning, RAG pipeline design, agent security audit (65-point checklist), eval harness building, and product sense coaching and the operator…

diegosouzapw/awesome-omni-skills · 81 tokens

zipai-optimizer

Skill "zipai-optimizer" from nickdesi/ZipAI, covering zipai: ultra-dense token optimizer, rules, 1. zero filler, 2. ambiguity and 3. prompt caching.

nickdesi/ZipAI · 4 tokens

azure-ai-projects-py

Build AI applications using the Azure AI Projects Python SDK (azure-ai-projects). Use when working with Foundry project clients, creating versioned agents with PromptAgentDefinition, running evalua...

rootcastleco/rei-skills · 45 tokens

azure-ai-projects-ts

Build AI applications using Azure AI Projects SDK for JavaScript (@azure/ai-projects). Use when working with Foundry project clients, agents, connections, deployments, datasets, indexes, evaluation...

rootcastleco/rei-skills · 45 tokens

ai-product

Every product will be AI-powered. The question is whether you'll build it right or ship a demo that falls apart in production. This skill covers LLM integration patterns, RAG architecture, prompt ...

rootcastleco/rei-skills · 43 tokens