The Overlapping Principles of Prompt Engineering and Software Development

Jacky Liang
3 min readJun 9, 2023

--

Photo by Gertrūda Valasevičiūtė on Unsplash

Hi, I am Jacky, a prompt engineer slash AI growth engineer working at Infinitus Systems. My job is to use generative AI to make folks around me more efficient, productive, and creative.

Disclaimer: these are my personal opinions and do not reflect the opinions of my employer Infinitus Systems. This post was not written with an LLM.

In the realm of artificial intelligence, I’ve come to hold a perspective that might not be universally accepted: Prompt engineering bears striking resemblances to professional software development. Before you dismiss this as an AI thoughtboi’s overreach, allow me to explain my stance.

Language Learning Models (LLMs) yield superior reasoning and outputs when the prompts fed to them are clear, concise, high-quality, and testable. Both prompt engineers and end-users can significantly benefit from the application of clean coding principles.

Prompt engineering bears striking resemblances to professional software development.

Clarity in Prompts

Prompts should be articulated in lucid English (or any language of your preference), adhering to proper grammar and spelling conventions. The format of prompts should maintain consistency across all prompt engineers within an organization. They should be easily readable, not requiring additional documentation or comments for comprehension. Moreover, they should be readily extendable, allowing colleagues to modify your prompt for their specific needs. The “variables” (base cases) and “functions” (specific instructions on input processing) should be well-defined, each responsible for a distinct part of the functionality.

Conciseness in Prompts

Prompts should encapsulate only the most crucial information. Few-shot reasoning (i.e., examples of an output) should be presented succinctly. The prompt should not add unnecessary context lengths, especially for models with low context limits. It should be free of superfluous texts that may distract from the essential parts of your prompt. Remember, even LLMs can err, particularly non-GPT-4 ones.

High-Quality Prompts

Prompts should effectively utilize advanced prompt engineering techniques such as few-shot, step-by-step, reflection, etc. They should implement repeatable modules and functions that have undergone rigorous testing, ready to be reused in other prompts. Furthermore, the prompt should be capable of handling exceptions, which can be particularly elusive in LLMs as they often manifest not as actual exceptions, but as inaccuracies in the output.

Testability and Peer-Reviewability of Prompts

The concept of functional testing should be implemented to ensure that improvements or changes to an LLM do not degrade or alter the outputs of prompts due to foundational model improvements and changes.

Adequate test cases should be applied to the prompt to ensure that both primary use cases and edge cases yield expected outputs. This is of paramount importance if you are productizing LLMs for enterprise use.

Prompts and their outputs should also undergo peer review and testing before being pushed live, to cover each prompter’s blind spots.

Testability and peer-reviewability also necessitate a central repository for your prompts, where team members can access, modify, and comment on them. Changes should be debated and approved.

The Intersection of Prompt Engineering and Coding

While prompt engineering is not coding per se, the principles of clean coding are surprisingly applicable to prompt engineering.

Robert C. Martin defines clean code as being:

- Readable
- Easily understandable
- Extendable
- Maintainable
- Version controllable
- Duplication-free
- Consistently formatted
- Capable of handling exceptions

These principles of clean code are equally relevant to clean prompts, especially as your organization expands its team of prompt engineers and end-users.

In my role as a prompt engineer at Infinitus, I’ve found that the more I craft prompts for various use cases, share them with colleagues, and receive feedback on inputs/outputs, the more I realize I’m leveraging the skills I honed as a software developer and product manager.

There are voices in the industry that claim prompt engineering is a dying field. I respectfully disagree. I believe we are only at the dawn of prompt engineering, with a vast landscape of possibilities yet to be explored. The principles of software development, particularly clean coding, can guide us on this journey, ensuring we create prompts that are clear, concise, high-quality, and testable — the keystones of effective prompt engineering.

In the next post, I will present 10 clean prompt engineering principles for your organization and team. Be sure to follow me to be the first to read it!

--

--

Jacky Liang

📍 Prompt engineer @ Infinitus. ⏪ Oracle Cloud. Singlestore. Looker (acq. Google).