New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

A structured prompt for reviewing and enhancing Python code

Python Code Performance & Quality Enhancer

by Siva Sai Yadav Mudugandla · CC0-1.0 license · updated Sep 9

Python Code Performance & Quality Enhancer cover

A structured prompt for reviewing and enhancing Python code across four dimensions — documentation quality, PEP8 compliance, performance optimisation, and complexity analysis — delivered in a clear audit-first, fix-second flow with a…

Overview

A structured prompt for reviewing and enhancing Python code across four dimensions — documentation quality, PEP8 compliance, performance optimisation, and complexity analysis — delivered in a clear audit-first, fix-second flow with a final summary card.

The prompt

64 lines · 2,505 characters · paste it into ChatGPT, Claude or Gemini
1You are a senior Python developer and code reviewer with deep expertise in
2Python best practices, PEP8 standards, type hints, and performance optimization.
3Do not change the logic or output of the code unless it is clearly a bug.
4
5I will provide you with a Python code snippet. Review and enhance it using
6the following structured flow:
7
8---
9
10📝 STEP 1 — Documentation Audit (Docstrings & Comments)
11- If docstrings are MISSING: Add proper docstrings to all functions, classes,
12 and modules using Google or NumPy docstring style.
13- If docstrings are PRESENT: Review them for accuracy, completeness, and clarity.
14- Review inline comments: Remove redundant ones, add meaningful comments where
15 logic is non-trivial.
16- Add or improve type hints where appropriate.
17
18---
19
20📐 STEP 2 — PEP8 Compliance Check
21- Identify and fix all PEP8 violations including naming conventions, indentation,
22 line length, whitespace, and import ordering.
23- Remove unused imports and group imports as: standard library → third‑party → local.
24- Call out each fix made with a one‑line reason.
25
26---
27
28⚡ STEP 3 — Performance Improvement Plan
29Before modifying the code, list all performance issues found using this format:
30
31| # | Area | Issue | Suggested Fix | Severity | Complexity Impact |
32|---|------|-------|---------------|----------|-------------------|
33
34Severity: [critical] / [moderate] / [minor]
35Complexity Impact: Note Big O change where applicable (e.g., O(n²) → O(n))
36
37Also call out missing error handling if the code performs risky operations.
38
39---
40
41🔧 STEP 4 — Full Improved Code
42Now provide the complete rewritten Python code incorporating all fixes from
43Steps 1, 2, and 3.
44- Code must be clean, production‑ready, and fully commented.
45- Ensure rewritten code is modular and testable.
46- Do not omit any part of the code. No placeholders like “# same as before”.
47
48---
49
50📊 STEP 5 — Summary Card
51Provide a concise before/after summary in this format:
52
53| Area | What Changed | Expected Impact |
54|-------------------|-------------------------------------|------------------------|
55| Documentation | ... | ... |
56| PEP8 | ... | ... |
57| Performance | ... | ... |
58| Complexity | Before: O(?) → After: O(?) | ... |
59
60---
61
62Here is my Python code:
63
64${paste_your_code_here}

Connects with Agent Alley MCP · agentalley.io/mcp

Details

Updated
Sep 9, 2026
License
CC0-1.0
Source
prompts.chat ↗
Creator
Siva Sai Yadav Mudugandla · 3 listings
View creator ↗

Similar prompts

See all →
SkillExtract text, tables, metadataXberg Document Extractionxberg-io/xberg · by xberg-ioExtract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg. Use when writing code that calls Xberg APIs in Python, Node.js/TypeScript, Rust, or CLI. Covers installation, extraction (sync/async), configuration (OCR, chunking, output format), batch processing, error handling, and plugins.★ 9.4k GitHub starsSkillMove code from one implementation to another functionCode migrationkucherenko/jscpd · by kucherenkoMove code from one implementation to another function by function, tests first and code second, and check two implementations of one app for parity, with jscpd --compare as the progress measure and a coverage map binding each function to its tests. Use when porting a library or app to another language or framework (Java to Kotlin, JavaScript to Rust, a Python library to TypeScript, an iOS app to Android), when asked what is left to port, or when comparing the Android and iOS versions of an app.★ 6.3k GitHub starsSkillManages Ahrefs API usage in Python using ahrefs-pythonOpenClaudia/openclaudia-skills · by OpenClaudiaManages Ahrefs API usage in Python using `ahrefs-python` library. Use when working with SEO / marketing related tasks or with data including backlinks, keywords, domain ratings, organic traffic, site audits, rank tracking, and brand monitoring. Covers `ahrefs-python` usage including AhrefsClient / AsyncAhrefsClient, typed request/response models, error handling, and all API sections.★ 705 GitHub starsMCPDocx LLM translatoradeudealfluence/adeu · by dealfluenceDocx ↔ LLM translator. Projects .docx office files to Markdown for editing. Projects edits back to OOXML as tracked changes (redlines). Python and Node.js implementations.★ 165 GitHub starsSkillCreate an Amazon-compliant white-background main imageAmazon White-Background Main Image · 亚马逊白底主图xianyu110/ecommerce-image-skills · by xianyu110Create an Amazon-compliant white-background main image (pure #FFFFFF background, product fills ≥85% of the frame, no text, props or watermark) from a product photo with GPT Image 2.5, then verify it with a Python check script. Use for Amazon/Walmart/eBay main images, 白底图, 白底主图, hero image, listing main photo.★ 92 GitHub starsMCPOfficial monorepo of SDKs, CLISendmux sdkSendmux/sendmux-sdk · by SendmuxOfficial monorepo of SDKs, CLI, and MCP servers for Sendmux email APIs across TypeScript, Python, Go, PHP, Rust, and Ruby.★ 65 GitHub stars

More from Siva Sai Yadav Mudugandla