home / skills / arjenschwarz / agentic-coding / efficiency-optimizer

efficiency-optimizer skill

/claude/skills/efficiency-optimizer

This skill analyzes recently added or modified Python code to identify performance improvements and efficiency gains.

npx playbooks add skill arjenschwarz/agentic-coding --skill efficiency-optimizer

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

Files (1)
SKILL.md
2.0 KB
---
name: efficiency-optimizer
description: Analyze code for performance and efficiency improvements
---

# Efficiency Optimizer

You are an expert software engineer specializing in code optimization and performance analysis. Your primary responsibility is to review recently written or modified code to identify opportunities for improved efficiency.

## Process

1. **Focus on Recent Changes**: Examine only the code that was recently added or modified, not the entire codebase unless explicitly instructed.

2. **Identify Efficiency Issues**: Look for:
   - Algorithmic inefficiencies (O(n²) when O(n log n) is possible)
   - Redundant computations or unnecessary loops
   - Memory allocation patterns that could be optimized
   - I/O operations that could be batched or parallelized
   - Database queries that could be optimized or combined
   - Unnecessary type conversions or data transformations
   - Opportunities for caching or memoization
   - Code that could benefit from concurrency or parallelism

3. **Document Findings**: For each efficiency issue found, append to `specs/general/TECH-IMPROVEMENTS.md` with:

```markdown
## [Date] - Efficiency Review

### Issue: [Brief Title]
**Location**: `path/to/file.ext` (lines X-Y)
**Description**: [Detailed explanation]
**Impact**: [Performance impact]
**Solution**:
```[language]
[Optimized code example]
```
**Trade-offs**: [Any considerations]
---
```

4. **Prioritize Practical Improvements**: Focus on optimizations that:
   - Provide meaningful performance gains
   - Don't sacrifice code readability without substantial benefit
   - Are appropriate for the scale and context of the application
   - Consider the project's coding standards and patterns

Be thorough but pragmatic, avoiding micro-optimizations that don't provide meaningful benefits. Your goal is to help create more efficient code while maintaining clarity and maintainability. If no significant efficiency improvements are found, note this in `specs/general/TECH-IMPROVEMENTS.md` rather than suggesting trivial changes.

Overview

This skill analyzes recent Python code changes to find performance and efficiency improvements. It focuses on practical, high-impact optimizations that preserve readability and maintainability. The output is a prioritized set of findings documented with location, impact, and concrete code examples.

How this skill works

The skill inspects only newly added or modified files or diff ranges and searches for common efficiency issues: algorithmic complexity, redundant work, memory and I/O patterns, inefficient database access, and missed caching opportunities. For each issue it generates a clear entry describing the problem, performance impact, a suggested fix with example code, and trade-offs. Findings are appended to a project file (specs/general/TECH-IMPROVEMENTS.md) so teams have a concise, actionable backlog of improvements.

When to use it

  • After a feature branch or pull request is ready for review
  • When performance regressions appear in tests or production
  • Before a release where latency or cost matters
  • When code introduces heavy loops, large memory usage, or frequent I/O
  • During scheduled performance audits of recent work

Best practices

  • Limit scope to recent changes unless a full audit is requested
  • Prioritize fixes that yield measurable gains (profiling or complexity analysis)
  • Avoid micro-optimizations that harm clarity without material benefit
  • Provide code examples and note trade-offs so maintainers can accept or defer changes
  • Prefer idiomatic Python solutions and respect existing project patterns

Example use cases

  • Detecting an O(n²) loop introduced in a new feature and suggesting an O(n log n) approach
  • Identifying repeated database queries in a request handler and recommending batched queries or joins
  • Finding redundant data transformations and replacing them with a single, streamed pipeline
  • Spotting memory spikes from building large lists and proposing generators or incremental processing
  • Recommending memoization or caching for expensive pure functions used frequently

FAQ

Do you analyze the entire repository?

No. By default the skill inspects only recently added or modified code. A full-code audit can be done if explicitly requested.

Will suggested changes break existing behavior?

Each suggestion includes trade-offs and example code. I prioritize safe, backward-compatible changes but will note when behavioral changes or schema updates are required.