askill
optimizing-tokens

optimizing-tokensSafety 98Repository

AI agent maximizes efficiency and minimizes costs through strategic token usage while maintaining output quality. Use when managing AI interactions, designing prompts, or reducing costs.

2 stars
1.2k downloads
Updated 1/8/2026

Package Files

Loading files...
SKILL.md

Optimizing Tokens

Quick Start

  1. Analyze - Identify input vs output token distribution
  2. Minimize Context - Read only relevant file sections, not entire files
  3. Optimize Prompts - Use direct commands, remove filler words
  4. Structure Outputs - Request concise formats (JSON over prose)
  5. Batch Operations - Combine related requests, avoid duplicate context
  6. Select Model - Match model tier to task complexity

Features

FeatureDescriptionGuide
Context TargetingRead only needed code sectionsLine ranges, pattern search, summaries
Prompt EfficiencyDirect commands vs verbose requests79% reduction possible
Output FormattingStructured concise responsesJSON/YAML over verbose explanations
Model SelectionRight model for task complexityHaiku: simple, Sonnet: standard, Opus: complex
BatchingCombine related operationsSingle request with multiple outputs
CachingAvoid redundant computationCache by content hash + timestamp

Common Patterns

# Prompt Optimization (79% reduction)
INEFFICIENT (120 tokens):
"I would really appreciate it if you could help me
with this task. What I need you to do is to please
analyze this code and look for any bugs..."

EFFICIENT (25 tokens):
"Analyze for bugs, error handling issues, security.
For each: location, problem, fix."

# Context Optimization
INEFFICIENT: Read entire 1000-line file
EFFICIENT: Read lines 45-60 around target function

# Output Format
INEFFICIENT: "Please explain in detail..."
EFFICIENT: "Output: JSON {name, severity, fix}"

# Batching
INEFFICIENT:
  Request 1: "Given code [100 lines], find bugs"
  Request 2: "Given code [same 100 lines], add types"

EFFICIENT:
  Single request: "Given code [100 lines]:
  1. Find bugs
  2. Add types"
# Model Selection Guide
| Task Type | Model | Examples |
|-----------|-------|----------|
| Simple | Haiku | Formatting, syntax check, lookups |
| Standard | Sonnet | Features, bugs, reviews, tests |
| Complex | Opus | Architecture, security, critical code |

# Search Efficiency
INEFFICIENT: grep ".*" / (matches everything)
EFFICIENT: grep "handleAuth" src/ --type ts

Best Practices

DoAvoid
Read only what's needed - use line rangesReading entire files for one function
Use direct language - commands over requestsVerbose, polite phrasing in prompts
Structure outputs - JSON/YAML over proseRequesting detailed explanations for simple tasks
Batch operations - combine related requestsRepeating context across multiple requests
Choose right model - Haiku for simple tasksUsing most powerful model for everything
Limit search results - use head_limitUnbounded searches returning thousands of results
Cache results - avoid redundant computationRe-analyzing unchanged files
Progressive loading - start minimal, expandLoading full context when partial suffices

Related Skills

  • dispatching-parallel-agents - Efficient multi-agent patterns
  • writing-plans - Structured planning reduces iteration
  • thinking-sequentially - Organized reasoning saves tokens

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

92/100Analyzed 2/20/2026

Well-structured skill on token optimization with clear Quick Start steps, practical before/after examples, and comprehensive best practices table. Includes model selection guidance and related skills. High actionability with concrete patterns for prompt optimization (79% reduction claimed), context targeting, and output formatting. No internal-only signals - applies broadly to any AI interaction scenario.

98
90
90
88
95

Metadata

Licenseunknown
Version-
Updated1/8/2026
Publisherdoanchienthangdev

Tags

promptingsecurity