Skip to chapter content

Chapter 4 3 min read

Giving the AI a Job — System Instructions

Role vs. request

Every prompt we’ve sent so far has been a bare question with nothing behind it. Ask an AI model something with no context and you get a generic, safe, forgettable answer, not because the model is bad, but because it has no idea who it’s supposed to be answering as.

There’s a fix for that, and it isn’t stuffing more instructions into the prompt itself. It’s a separate piece of configuration called a system instruction.

Prompt vs. system instruction

Think about handing a task to a freelancer. You could just message them “write something about our new muffin” and hope for the best. Or you could brief them first: who the brand is, what tone to use, what to avoid, and then hand them the actual task. Same task, very different result, because the second freelancer isn’t guessing.

A system instruction is that briefing. The prompt is still the specific ask (with_text(), or the string you pass directly), but the system instruction sits above it and shapes how the model approaches every prompt in that request: what role it’s playing, what tone to use, what it should never do. It’s set with one method:

->using_system_instruction( 'You are a senior WordPress developer writing precise technical documentation.' )

Chain that onto a builder before calling generate_text(), and the model answers as that persona instead of as a generic assistant.

Seeing the difference

The clearest way to understand this is to run the exact same prompt twice, once with no system instruction, once with one, and compare. Create chapter-04-system-instructions.php inside includes:

<?php
/**
* Chapter 4: Giving the AI a Job, System Instructions
* Usage: add [ai_course_ch4] to any page or post to see the output.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access.
}
function ai_course_ch4_system_instruction() {
$prompt = 'We just added a new item to our menu: a lemon poppyseed muffin. Announce it.';
$without_role = wp_ai_client_prompt( $prompt )->generate_text();
if ( is_wp_error( $without_role ) ) {
return 'Could not generate the first example: ' . esc_html( $without_role->get_error_message() );
}
$with_role = wp_ai_client_prompt( $prompt )
->using_system_instruction( 'You are the social media voice of a small, family-run neighborhood bakery. Write warm, casual, slightly playful captions. Never sound corporate.' )
->generate_text();
if ( is_wp_error( $with_role ) ) {
return 'Could not generate the second example: ' . esc_html( $with_role->get_error_message() );
}
$output = '<p><strong>Without a system instruction:</strong><br>' . wp_kses_post( $without_role ) . '</p>';
$output .= '<p><strong>With a system instruction:</strong><br>' . wp_kses_post( $with_role ) . '</p>';
return $output;
}
add_shortcode( 'ai_course_ch4', 'ai_course_ch4_system_instruction' );

Add [ai_course_ch4] to a page and load it. The first paragraph is what you’d expect from Chapter 2’s approach, competent, but interchangeable with an announcement for any bakery, or honestly any business selling any product. The second one sounds like it came from an actual small bakery’s Instagram account. Same exact request both times, sent to the same model, the only thing that changed is who it was told to be.

Why this isn’t just a longer prompt

You could try to get a similar result by writing all of that context directly into the prompt string every time, “write this as a warm, casual, family bakery voice, announce our new muffin.” It would sort of work. But you’d be repeating that persona in every single prompt across your plugin, and if the client wants to adjust their brand voice later, you’re hunting through every prompt string in your codebase to update it.

A system instruction is set once per request and can be reused across many different prompts. Define the bakery’s voice once, and every different announcement, caption, or reply you generate through that configuration inherits it automatically, without retyping the brief each time.

Try it yourself

Write a system instruction for something real, your own plugin’s support responses, a client’s brand voice, a specific technical role you want the AI to answer as. Run one prompt through it with and without the instruction, the same comparison pattern as above, and see how much the answer changes. If the difference feels small, the system instruction probably needs to be more specific than “be professional,” try naming an actual tone, audience, or constraint instead.

This book is created with Chapterwright