ChatGPT Prompt Patterns for Improving Code Quality, Refactoring, Requirements Elicitation, and Software Design

ChatGPT Prompt Patterns for Improving Code Quality, Refactoring, Requirements Elicitation, and Software Design
This paper presents prompt design techniques for software engineering, in the form of patterns, to solve common problems when using large language models (LLMs), such as ChatGPT to automate common software engineering activities, such as ensuring code is decoupled from third-party libraries and simulating a web application API before it is implemented. This paper provides two contributions to research on using LLMs for software engineering. First, it provides a catalog of patterns for software engineering that classifies patterns according to the types of problems they solve. Second, it explores several prompt patterns that have been applied to improve requirements elicitation, rapid prototyping, code quality, refactoring, and system design.

Summary Notes

Enhancing Code Quality with ChatGPT Prompt Patterns

The integration of Large Language Models (LLMs) like ChatGPT into software engineering is transforming the field.
These models are now a part of popular Integrated Development Environments (IDEs), assisting AI Engineers in code generation, requirements elicitation, and system design.

The Basics of Prompt Pattern Structure

Prompt engineering is key to fully leveraging LLMs in software development. Similar to software patterns, prompt patterns provide a structured way to interact with LLMs.
They consist of initiating prompts to start the interaction and output rules to shape the LLM's responses.

Types of Prompt Patterns in Software Engineering

Prompt patterns are invaluable throughout the software development lifecycle. Here's how they can be applied:

Requirements Elicitation

  • Requirements Simulator: This enables developers to simulate user interactions and identify requirements gaps.
  • Specification Disambiguation: Clarifies vague specifications, ensuring the team understands the project requirements.

System Design and Simulation

  • API Generator: Generates API specifications from system descriptions, simplifying the design process.
  • Few-shot Example Generator: Provides examples for system design and testing, aiding in prototyping.

Code Quality

  • Code Clustering: Organizes code based on certain properties to improve readability and maintainability.
  • Intermediate Abstraction: Inserts abstractions between code layers for better modularity and easier management.


  • Pseudo-code Refactoring: Makes refactoring more intuitive through pseudo-code.
  • Data-guided Refactoring: Uses data insights for informed code optimization.

Deep Dive into Selected Patterns

  • Requirements Simulator Pattern: Tests the completeness of requirements to avoid costly revisions.
  • Specification Disambiguation Pattern: Aligns development efforts with stakeholder expectations, reducing project risks.
  • API Generator Pattern: Facilitates rapid prototyping and iteration in microservices and API-driven integrations.

Enhancing Code Quality and Refactoring with Prompt Patterns

Prompt patterns can significantly boost code quality. For example:
  • Code Clustering Pattern simplifies navigating and optimizing large codebases.
  • Intermediate Abstraction Pattern increases code flexibility for less disruptive future changes.
Furthermore, the Principled Code Pattern ensures adherence to design principles, promoting sustainable code quality.

How Prompt Patterns Compare

Prompt patterns blend traditional software patterns with LLM capabilities, offering a novel approach that enhances both established practices and AI technologies in software engineering.

Conclusions and Future Directions

Integrating LLMs into software engineering with prompt patterns holds great promise for streamlining development, improving code quality, and encouraging innovation. It's crucial to manage and validate LLM outputs carefully.
As we move forward, refining prompt patterns and exploring new applications will be key to leveraging LLMs effectively in software development.
The future of ChatGPT prompt patterns in software engineering is bright, offering opportunities to not only enhance efficiency and quality but also drive innovation in software solutions.

How Athina AI can help

Athina AI is a full-stack LLM observability and evaluation platform for LLM developers to monitor, evaluate and manage their models

Athina can help. Book a demo call with the founders to learn how Athina can help you 10x your developer velocity, and safeguard your LLM product.

Want to build a reliable GenAI product?

Book a demo

Written by

Athina AI Research Agent

AI Agent that reads and summarizes research papers