home / skills / jeremylongshore / claude-code-plugins-plus-skills / optimizing-prompts

This skill optimizes prompts for LLMs to reduce token usage, lower costs, and speed up responses without sacrificing quality.

npx playbooks add skill jeremylongshore/claude-code-plugins-plus-skills --skill optimizing-prompts

Review the files below or copy the command above to add this skill to your agents.

Files (10)
SKILL.md
3.9 KB
---
name: optimizing-prompts
description: |
  Execute this skill optimizes prompts for large language models (llms) to reduce token usage, lower costs, and improve performance. it analyzes the prompt, identifies areas for simplification and redundancy removal, and rewrites the prompt to be more conci... Use when optimizing performance. Trigger with phrases like 'optimize', 'performance', or 'speed up'.
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(cmd:*)
version: 1.0.0
author: Jeremy Longshore <[email protected]>
license: MIT
---
# Ai Ml Engineering Pack

This skill provides automated assistance for ai ml engineering pack tasks.

## Overview


This skill provides automated assistance for ai ml engineering pack tasks.
This skill empowers Claude to refine prompts for optimal LLM performance. It streamlines prompts to minimize token count, thereby reducing costs and enhancing response speed, all while maintaining or improving output quality.

## How It Works

1. **Analyzing Prompt**: The skill analyzes the input prompt to identify areas of redundancy, verbosity, and potential for simplification.
2. **Rewriting Prompt**: It rewrites the prompt using techniques like concise language, targeted instructions, and efficient phrasing.
3. **Suggesting Alternatives**: The skill provides the optimized prompt along with an explanation of the changes made and their expected impact.

## When to Use This Skill

This skill activates when you need to:
- Reduce the cost of using an LLM.
- Improve the speed of LLM responses.
- Enhance the quality or clarity of LLM outputs by refining the prompt.

## Examples

### Example 1: Reducing LLM Costs

User request: "Optimize this prompt for cost and quality: 'I would like you to create a detailed product description for a new ergonomic office chair, highlighting its features, benefits, and target audience, and also include information about its warranty and return policy.'"

The skill will:
1. Analyze the prompt for redundancies and areas for simplification.
2. Rewrite the prompt to be more concise: "Create a product description for an ergonomic office chair. Include features, benefits, target audience, warranty, and return policy."
3. Provide the optimized prompt and explain the token reduction achieved.

### Example 2: Improving Prompt Performance

User request: "Optimize this prompt for better summarization: 'Please read the following document and provide a comprehensive summary of all the key points, main arguments, supporting evidence, and overall conclusion, ensuring that the summary is accurate, concise, and easy to understand.'"

The skill will:
1. Identify areas for improvement in the prompt's clarity and focus.
2. Rewrite the prompt to be more direct: "Summarize this document, including key points, arguments, evidence, and the conclusion."
3. Present the optimized prompt and explain how it enhances summarization performance.

## Best Practices

- **Clarity**: Ensure the original prompt is clear and well-defined before optimization.
- **Context**: Provide sufficient context to the skill so it can understand the prompt's purpose.
- **Iteration**: Iterate on the optimized prompt based on the LLM's output to fine-tune performance.

## Integration

This skill integrates with the `prompt-architect` agent to leverage advanced prompt engineering techniques. It can also be used in conjunction with the `llm-integration-expert` to optimize prompts for specific LLM APIs.

## Prerequisites

- Appropriate file access permissions
- Required dependencies installed

## Instructions

1. Invoke this skill when the trigger conditions are met
2. Provide necessary context and parameters
3. Review the generated output
4. Apply modifications as needed

## Output

The skill produces structured output relevant to the task.

## Error Handling

- Invalid input: Prompts for correction
- Missing dependencies: Lists required components
- Permission errors: Suggests remediation steps

## Resources

- Project documentation
- Related skills and commands

Overview

This skill optimizes prompts for large language models to reduce token usage, lower costs, and improve runtime performance. It streamlines wording and removes redundancy while preserving or improving the instruction clarity and expected output. Use it to make prompts more efficient for production or experimentation.

How this skill works

The skill analyzes the supplied prompt to detect verbosity, duplicate instructions, and ambiguous phrasing. It rewrites the prompt using concise language, targeted directives, and prioritized constraints to reduce token count. It returns the optimized prompt plus an explanation of changes, token savings estimates, and suggested variants for different trade-offs (brevity vs. explicitness).

When to use it

  • You want to cut API costs by reducing tokens per call.
  • Responses are slow and you need faster turnaround without losing quality.
  • The model output is inconsistent and prompt clarity may help.
  • Preparing prompts for high-throughput or real-time systems.
  • Before scaling prompts across multiple LLMs or environments.

Best practices

  • Provide the full original prompt and any required context for accurate optimization.
  • State your primary objective (cost, speed, accuracy) so rewrites match priorities.
  • Keep key constraints explicit; don’t remove essential requirements when shortening.
  • Test optimized prompts with real inputs and iterate based on model behavior.
  • Use suggested variants when balancing brevity and specificity for different models.

Example use cases

  • Convert a long product brief into a compact instruction that preserves output structure and details.
  • Trim a multi-step data-extraction prompt to reduce tokens while keeping parsing reliability.
  • Produce a short high-priority prompt for low-latency inference in an interactive application.
  • Generate both a concise and a verbose variant so you can A/B test cost vs. fidelity.
  • Optimize prompts for deployment across different LLM providers with varied token pricing.

FAQ

Will optimization change the output meaning?

The goal is to preserve meaning; the skill flags any change-risk and offers variants that prioritize fidelity over token savings.

How do you estimate token savings?

Estimates are based on token-count heuristics for common LLM tokenizers and the reduction in prompt length; actual savings vary by model.