Cross-Platform Code Refactor
Clear constraints (don't change behavior, same public API) prevent over-engineering. The changelog forces the model to justify each change.
Refactor this {{language}} code to improve readability and maintainability. Do NOT change the external behavior. Requirements: - Extract functions longer than 20 lines into smaller, well-named helpers - Replace magic numbers with named constants - Add brief docstrings to each function - Keep the same public API Return the refactored code followed by a changelog of what you changed and why. \`\`\` {{paste your code}} \`\`\`
Variables to customize
Why this prompt works
Clear constraints (don't change behavior, same public API) prevent over-engineering. The changelog forces the model to justify each change.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Forcing the agent to plan before acting prevents premature execution and wasted steps. Explicit dependency mapping enables parallel execution and catches logical gaps early.
Tool Selection AgentThe ReAct pattern (Reason + Act) creates an explicit reasoning trace that improves tool selection accuracy. The error-handling rule prevents infinite retry loops.
Prompt CompressorExplicitly requiring all functional requirements to be preserved prevents the model from over-compressing and losing critical instructions.
Memory Management AgentExplicit memory read/write instructions create agents that improve over time. Categorization keeps memories organized, and the deduplication rule prevents context bloat.