# Improve Code Performance

> Finds likely bottlenecks and suggests measurable performance improvements.

## Best For

- Finds likely bottlenecks and suggests measurable performance improvements.
- Work involving coding and performance
- Producing a copy-ready deliverable with explicit accuracy rules

## Recommended AI

- ChatGPT
- Claude
- Gemini

## Difficulty

Advanced

## Information to Provide

- [INSERT TOPIC OR SOURCE MATERIAL]
- [INSERT GOAL]
- [INSERT AUDIENCE]
- [INSERT REQUIREMENTS]
- [INSERT CONSTRAINTS]
- [INSERT OUTPUT FORMAT]
- [INSERT TONE OR STYLE]
- [INSERT DEADLINE OR LENGTH IF RELEVANT]

## Quick Prompt

```text
Act as a senior software engineer, code reviewer, and technical mentor. Your objective is to deliver the result described here: Finds likely bottlenecks and suggests measurable performance improvements.

Use this context: [INSERT TOPIC OR SOURCE MATERIAL]. Goal: [INSERT GOAL]. Audience: [INSERT AUDIENCE]. Requirements: [INSERT REQUIREMENTS]. Constraints: [INSERT CONSTRAINTS]. Output format: [INSERT OUTPUT FORMAT].

Establish a baseline, analyze time and space costs, recommend profiling, and rank optimizations by impact and risk. Avoid premature micro-optimization, unmeasured speed claims, or changes that silently alter behavior. Do not invent missing facts. If a missing detail is essential, ask up to three focused questions; otherwise state a reasonable assumption. Return the requested code or analysis in clearly labeled sections, with runnable snippets, assumptions, and verification steps.
```

## Advanced Prompt

```text
Act as a senior software engineer, code reviewer, and technical mentor.

OBJECTIVE
Deliver the result described here: Finds likely bottlenecks and suggests measurable performance improvements.

CONTEXT
- Topic or source material: [INSERT TOPIC OR SOURCE MATERIAL]
- Goal or decision this must support: [INSERT GOAL]
- Intended audience: [INSERT AUDIENCE]
- Known background and evidence: [INSERT CONTEXT AND VERIFIED FACTS]
- Platform, environment, or channel: [INSERT PLATFORM]

REQUIREMENTS
1. Establish a baseline, analyze time and space costs, recommend profiling, and rank optimizations by impact and risk.
2. Follow these user requirements: [INSERT REQUIREMENTS].
3. Respect these constraints: [INSERT CONSTRAINTS].
4. Match this tone or style: [INSERT TONE OR STYLE].
5. Use this target length or deadline when relevant: [INSERT LENGTH OR DEADLINE].
6. Make the result specific to the code, programming language, environment, expected behavior, and constraints; do not produce a generic answer.
7. Check the final result for internal consistency, missing steps, and unusable ambiguity.

ACCURACY AND BOUNDARIES
- Do not invent facts, quotations, sources, product features, statistics, experience, or results.
- Clearly label assumptions, estimates, and inferences.
- When current or external facts are required and browsing is available, verify them with reliable sources and cite direct links.
- When required evidence is unavailable, write [NEEDS VERIFICATION] or ask a focused question instead of guessing.
- Avoid premature micro-optimization, unmeasured speed claims, or changes that silently alter behavior.

OUTPUT
Return the requested code or analysis in clearly labeled sections, with runnable snippets, assumptions, and verification steps.
Use this exact requested format: [INSERT OUTPUT FORMAT].
Begin with the finished deliverable. Put assumptions, verification needs, or optional alternatives afterward.
```

## Example Input

```text
Topic: Python task manager; Goal: add persistent JSON storage; Audience: a beginner developer; Requirements: type hints and error handling; Constraints: standard library only, Python 3.12; Output: changed files, code, and test commands.
```

## Customization Options

* Tone
* Length
* Audience
* Detail level
* Output format
* Platform or AI model

## Expected Output

Return the requested code or analysis in clearly labeled sections, with runnable snippets, assumptions, and verification steps. The result should directly address the stated goal, preserve supplied facts, label assumptions, and be usable without another rewrite.

## Related Prompts

* [Write Automated Tests](Write%20Automated%20Tests.md)
* [Improve Code Security](Improve%20Code%20Security.md)
