liveBook · Manning

Persona pattern

As explained in AI-Powered Developer: Build software with ChatGPT and Copilot

The Persona Pattern is a prompt-engineering pattern that directs an AI system to respond as a specified role or to treat the user as a specified persona.

The Persona Pattern directs an AI system to respond as a specified role or to treat the user as a specified audience. A defined persona can make replies more consistent and contextually appropriate, but identical prompts can still produce different outputs. section 2.1.1 section 2.5

Use the pattern to shape both the work being requested and the way an explanation is delivered:

  • Assign an intern persona to produce pseudocode, implementations, documentation, or a test harness for a programming task. section 2.1.1
  • Assign an audience persona when complex code needs to be explained to someone without computer-science experience. section 2.1.2
  • Assign a software-architect persona when exploring requirements, system functionality, package structure, or component-level design. section 3.2

From role to working example

A prompt can ask ChatGPT to act as a computer-science intern and define a singly linked list in Python, including nodes, links, insertion, and traversal. The resulting implementation includes ListNode and SinglyLinkedList classes with append, prepend, and traverse methods. A follow-up persona prompt can cast the user as a communications graduate with no computer-science experience, producing a bookshelf analogy for reversing node links. section 2.1.1 section 2.1.2

Assume that you are a software architect, and you are designing an information technology asset management system, using Python. The system should be able to maintain a complete inventory of all hardware and software assets owned by an organization. The system should be able to track asset location, status, and usage. This includes information such as who uses the asset, when it was last serviced, and when it is due for replacement. The system should be able to manage the entire lifecycle of an asset, from procurement to disposal. This includes tracking warranty and lease information, managing asset maintenance and repair, and ensuring compliance with regulations. The system should be able to allocate assets to employees or departments, track usage, and manage reservations for assets that are in high demand. It should use hexagonal architecture. Remember to enhance my prompt.

A complete software-architect prompt demonstrates how a persona can be combined with Python, asset-lifecycle requirements, and hexagonal architecture; the resulting overview and package structure show progressively refined design output. section 3.2

How AI-Powered Developer: Build software with ChatGPT and Copilot covers it

How deep it goes
Defines role and audience variations and demonstrates them through linked-list and system-design prompts, while stopping short of guaranteed outputs.
Examples
Uses intern prompts for Python linked lists, nontechnical bookshelf explanations, and architect prompts for an asset-management system.
What it assumes
Builds from ordinary questions and progressively specific prompts, while supporting explanations for audiences without computer-science experience.
What you can do after
Apply it via ChatGPT to request role-specific code, explanations, refined prompts, or preliminary software designs.
How it connects
Connects prompt engineering with the Refinement Pattern, Audience Persona Pattern, large language models, linked lists, and software architecture.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI-Powered Developer: Build software with ChatGPT and Copilot. The section links point to the parts of the book it draws on.