prompt-caching-strategy
ما الذي تفعله
تساعد هذه المهارة في خفض التكاليف وتسريع ردود الذكاء الاصطناعي، من خلال تنظيم التعليمات التي ترسلها إليه بشكل أفضل. تضمن أن الأجزاء المتكررة من تعليماتك تبقى ثابتة، حتى يتمكن الذكاء الاصطناعي من إعادة استخدام الإجابات السابقة.
متى تستخدمها
- ✓عندما ترسل طلبات متشابهة جدًا إلى الذكاء الاصطناعي بشكل متكرر.
- ✓إذا أردت أن يرد الذكاء الاصطناعي بسرعة أكبر.
- ✓لخفض تكلفة استخدام خدمات الذكاء الاصطناعي.
رابط المهارة
https://github.com/affaan-m/ECC/blob/main/skills/prompt-caching-strategy/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“كيف أنظّم أوامري حتى يستخدم الذكاء الاصطناعي التخزين المؤقت (cache) ويدفع أقل؟”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تقترح الأداة فصل الجزء الثابت من التعليمات، مثل القواعد والأمثلة، عن الجزء الذي يتغير في كل مرة، مثل السؤال الحالي. وبهذا يستطيع الذكاء الاصطناعي التعرف على الأجزاء الثابتة وإعادة استخدامها بسهولة أكبر.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Prompt Caching Strategy
Arrange reusable prompt content to improve cache reuse, then measure input cost and latency. Savings depend on model, platform, cache eligibility, writes, retention, reuse and output volume. Runtime cache hits and savings for this skill are unmeasured; the examples below validate arithmetic without provider calls.
When to Activate
Use for repeated API requests that share authorized instructions, tools or reference material. First identify the exact provider endpoint, model, service tier and caching mode. Consult its current documentation before selecting rates, minimum prefix length or retention. Caching does not reduce context-window use.
How It Works
Preserve a stable prefix
Keep reusable instructions, tool schemas and examples stable; place changing questions, timestamps and retrieved results after that content where the API allows. Respect the provider's serialization order: Claude uses tools, system, then messages. Matching prefixes need identical content, including tool schemas and relevant request settings. A changed prefix can prevent reuse from that point. A dynamic suffix may itself be cached later if reused unchanged.
Reusable prefix: approved tools, instructions, stable examples/reference
Changing suffix: current question, fresh retrieval results, request metadata
Choose only relevant context. Padding prompts or broadening access just to meet an eligibility threshold needs its own cost and quality justification.
Preserve user and workspace boundaries
Authorize content access before cache lookup or reuse. Scope application-managed cache handles and accounting keys to the approved user, workspace, provider account, model and content revision. Share only material explicitly approved for that scope. A cache key is a routing/accounting hint, not an authorization gate or a sandbox. Provider cache isolation does not replace application access checks. Invalidate application references when permissions or content change; follow provider retention/deletion controls. Avoid logging private prompt contents. Context selection, capabilities, sandbox enforcement and evidence remain independent of cache optimization.
Provider Requirements and Usage Evidence
The linked documentation is authoritative; endpoint and SDK versions can expose different usage field names. Record that version alongside counters.
| Provider | Requirements to verify | Counters to record |
|---|---|---|
| OpenAI | Model-specific automatic/explicit modes, minimum length, retention and write/read prices; earlier and newer models differ | Responses usage.input_tokens_details.cached_tokens and, when present, cache_write_tokens; input and output totals. Chat Completions uses prompt_tokens_details.cached_tokens |
| Claude | Supported platform, model minimum, cache_control support and TTL; cache writes may cost more than ordinary input |
input_tokens, cache_creation_input_tokens, cache_read_input_tokens, output_tokens; split writes by TTL when rates differ |
| Gemini | Model minimum and API: Interactions supports implicit caching; explicit cache objects require GenerateContent | Interactions usage.total_cached_tokens; GenerateContent usage_metadata cache/input/output counters plus explicit-cache token count and retained duration |
Use OpenAI's prompt caching guide and pricing for the selected model. For Chat Completions, check the usage schema. Derive ordinary input from the total minus cached reads and any separately reported writes; do not count the same tokens twice.
Use Claude's prompt caching guide
for current model/platform limits and TTL rates. Its input_tokens counts
ordinary input separately from cache reads and writes. A short prefix can produce
zero cache counters even when marked for caching. Do not assume every Claude
model or hosted platform uses the same minimum or read price.
Use Gemini's caching guide, GenerateContent caching guide and pricing. Explicit-cache
…
الأسئلة الشائعة
ما هو «cache»؟
الـ cache ذاكرة مؤقتة يخزن فيها الذكاء الاصطناعي إجاباته على الأسئلة التي سُئلت من قبل. فإذا كان السؤال نفسه، يستخدم الإجابة المخزنة بدلًا من حساب كل شيء من جديد.
هل يعمل هذا مع أي ذكاء اصطناعي؟
يعمل مع بعض النماذج المحددة، مثل OpenAI وClaude. وتحتاج إلى مراجعة الوثائق الخاصة بكل نموذج لمعرفة طريقة إعداده.
هل يقلل التخزين المؤقت حجم نافذة السياق؟
لا، التخزين المؤقت لا يقلل استخدام نافذة السياق لدى الذكاء الاصطناعي. بل يساعد فقط على إعادة استخدام المعلومات لجعل العملية أسرع وأرخص.
التفاصيل
الوصف الأصلي من المؤلف
Optimize LLM prompt caching hit rate to reduce API costs and improve latency. Analyzes prompt structure, identifies cacheable vs non-cacheable content, and recommends restructuring to maximize cache reuse. TRIGGER when: user says "prompt cache", "cache hit rate", "reduce LLM cost", "optimize token usage", "cheaper LLM calls", or asks about prompt caching strategies for OpenAI/Anthropic/other provi
repo: affaan-m/ECC
الشعبية
- نجوم GitHub
- 280k
- الترتيب
- #386
- الترخيص
- MIT
- آخر تحديث
- 15/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
accessibility
280kيساعد وكيلك على بناء واجهات يستطيع الجميع استعمالها، ويضمن عمل المواقع والتطبيقات جيدًا لذوي الإعاقة، كالمكفوفين وذوي الحركة المحدودة.
agent-architecture-audit
280kيتأكد وكيلك من أن كل شيء يعمل بشكل صحيح، ويجد مشكلات أنظمة الذكاء الاصطناعي ويصلحها، ليؤدي كما هو متوقع.
agent-eval
280kيساعد وكيلك على مقارنة أدوات البرمجة بالذكاء الاصطناعي المختلفة، ويقيس أيها أسرع وأرخص وأكثر موثوقية لمهام محددة.
agent-harness-construction
280kيساعد وكيلك على فهم طريقة إنجاز المهام بشكل أفضل، عبر تحسين الأدوات والتعليمات التي يستعملها لزيادة فرص نجاحه.
مهارات مشابهة
writing-skills
311kيعلّم وكيلك كتابة مهارات جديدة واختبار كل واحدة أولًا، والتأكد من أنها تغيّر سلوك الوكيل فعلًا.
writing-for-agents
310kيشرح كيفية كتابة تعليمات واضحة لوكلاء الذكاء الاصطناعي، بما في ذلك ملفات المهارات وAGENTS.md وCLAUDE.md، ليتصرف الوكيل بشكل متوقع.
dspy
260kيساعد وكيلك على بناء برامج الذكاء الاصطناعي بتحديد المدخلات والمخرجات بدل كتابة كل أمر يدويًا، ثم ضبط الأوامر من بيانات أمثلة.