Skip to content
Back to skills

Coding

ASecurity

Cut token cost and latency in LLM systems: context pruning, prompt size, RAG chunking and re-ranking, model routing, caching. Use when an LLM feature is slow or expensive, or when its context window or retrieval quality is the limit.

  • 24 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added October 14, 2026
ai-agentsgoperformance

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned November 22, 2026

npx -y skills add andreibesleaga/GABBE --skill coding --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coding?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coding
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-coding-f473a283/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-coding-f473a283)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: performant-ai
description: "Cut token cost and latency in LLM systems: context pruning, prompt size, RAG chunking and re-ranking, model routing, caching. Use when an LLM feature is slow or expensive, or when its context window or retrieval quality is the limit."
triggers: [ai, llm, performance, context window, tokens, prompt engineering, rag, inference, latency]
tags: [coding, ai, architecture]
context_cost: medium
---
# Performant AI Skill

## Goal
Optimizing the interaction, speed, and cost-effectiveness of LLM-based systems by mastering context management and inference strategies.

## Capabilities

### 1. Context Window Engineering
- **Context Pruning**: Implement logic to remove irrelevant or redundant tokens from the prompt to fit within limits and reduce cost.
- **Summarization Chains**: Use "recursive summarization" for long conversations or documents.
- **Observation Masking**: Hide older or less critical data to keep the attention of the model on the immediate task.

### 2. Efficient Prompting (Latency & Cost)
- **Few-Shot Optimization**: Minimize the number of examples to the bare minimum needed for accuracy.
- **Output Structuring**: Use JSON mode or structured outputs to reduce parsing errors and retry loops.
- **Prompt Compression**: Use tools or manual techniques to shorten instructions without losing semantic meaning.

### 3. RAG Optimization (Retrieval-Augmented Generation)
- **Chunking Strategy**: Optimize chunk sizes and overlap for the specific domain (e.g., small chunks for semantic search, large for summaries).
- **Hybrid Search**: Combine Vector search (semantic) with Keyword search (BM25) for higher precision.
- **Re-ranking**: Use a secondary, smaller model to re-rank the top-K results before sending them to the expensive LLM.

### 4. Inference & Routing Strategies
- **Brain Mode Routing**: Arbitrate between "Local" models (faster/cheaper) and "Remote" models (complex/slower) based on task difficulty.
- **Speculative Decoding**: (Where possible) use smaller models to draft tokens for larger models to verify, speeding up generation.
- **Cache Hits**: Implement semantic caching (Redis) to reuse LLM responses for similar queries.

### 5. Architectural Patterns
- **Self-Correction Loops**: Build reflection phases into the agent flow to catch errors early.
- **Asynchronous Agents**: Run independent research or tool calls in parallel to reduce perceived latency (Loki Mode).

## Steps
1. **Token Audit**: Trace the token count of typical requests to find "bloat" in systemic prompts.
2. **Latency Mapping**: Break down Time-to-First-Token (TTFT) and Total Generation Time.
3. **Retrieval Benchmark**: Measure the Hit Rate and Recall of the RAG pipeline.
4. **Cost Projection**: Estimate monthly burn based on different model providers and context sizes.

## Output Format
- `COST_OPTIMIZATION_REPORT_TEMPLATE.md`: Analysis of prompt efficiency and LLM token usage.
- `ARCHITECTURE_REVIEW_TEMPLATE.md`: Configuration for vector DB, chunking, and search weights.
- `SCALABILITY_ANALYSIS_TEMPLATE.md`: Logic table for local vs remote model selection and context scaling.

## Constraints
- Measure before and after each change (tokens, time to first token, retrieval hit rate); a cost projection is an estimate with its assumptions stated.
- Keep a fallback path when the primary model fails or is rate-limited.

## Limits and safety
- Remove or mask personal data before it goes to a remote model provider, and check that RAG retrieval respects the asking user's access rights.
- Set a token or cost cap per session before starting an autonomous loop, and stop at the cap.
- At most 5 reflection or self-heal attempts, as in `self-heal.skill`.
- Check critical facts the model produced against a source, and keep a conservative fallback for a failed or rate-limited model.

Files in this skill

  • agent-trajectory-eval.skill.md5.7 KB
  • artisan-commands.skill.md3.7 KB
  • browser-tdd.skill.md7 KB
  • chaos-fault-injection.skill.md8.1 KB
  • ci-autofix.skill.md4.2 KB
  • clean-coder.skill.md4.5 KB
  • code-review.skill.md6.1 KB
  • debug.skill.md6.5 KB
  • documentation.skill.md7.3 KB
  • eval-driven-development.skill.md6.9 KB
  • evals/code-review.eval.yaml1 KB
  • excalidraw.skill.md3.7 KB
  • file-processing.skill.md4.3 KB
  • git-workflow.skill.md7.2 KB
  • metamorphic-testing.skill.md7.8 KB
  • mobile-dev.skill.md4.2 KB
  • nodejs-expert.skill.md1.6 KB
  • output-validation.skill.md5.4 KB
  • pbt-strategy.skill.md8 KB
  • performant-ai.skill.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.