
Module 1: Context Setting & Architecture Definition
1. Overview & Learning Objectives
A large language model does not automatically know your domain, your standards, or what you are trying to build. Without context, it defaults to generic patterns, common clichés, or plausible-sounding guesses.
In this module, you will learn how to ground an AI before asking it to act—whether you are using it for general work or generating code for an application. By the end of this module, you will be able to:
- Establish a clear Role / Persona and Audience so the model pitches its reasoning and communication style at the right level.
- Supply Background & Domain Context (including facts, source material, and system boundaries) so outputs stay anchored to reality rather than assumptions.
- Define Architecture & Core Functionality up front when building software so the code fits together cleanly from the start.
2. Why Context Comes First
Think of context as setting the stage and handing over the brief before anyone starts working:
- For general AI tasks: Telling the model who it is acting as, who the output is for, and what information is true stops vague or overly generic answers.
- For application code: Telling the model what kind of application it is building, how components relate, and what core behaviour is required prevents disconnected snippets and mismatched assumptions.
3. Core Building Blocks
A. General AI Application
- Role / Persona: The expertise or perspective the AI should adopt (e.g., an editor, analyst, or technical reviewer).
- Audience: Who will read or use the result, and what level of detail or terminology suits them.
- Ground Truth & Background: The specific facts, notes, or constraints the AI must rely on—and a clear rule not to invent missing details.
B. Application Code Generation
- Application Type & Scope: What is being built (e.g., a web app, CLI tool, API service, or interactive widget) and what is in vs. out of scope.
- Core Functionality: The primary user journeys or behaviours the application must support.
- Design Pattern / Structure: How the code should be organised (e.g., modular components, separation of concerns, clear data flow) so it can grow without turning into spaghetti.
4. Workflow Diagram (Text & Mermaid)
Use this flow when drafting the Context Setting / Architecture Definition stage of a prompt:
Plaintext
[Raw Idea / Input Material]
│
▼
[Define Role & Target Audience] (or [Application Type & Scope])
│
▼
[Provide Ground Truth & Facts] (or [Core Functionality & Pattern])
│
▼
[Grounded Base Prompt / Spec] ──► Ready for Task / Stack Definition
5. Practical Examples
Example 1: General Application (Career / CV Review)
Context: You are acting as a strict technical hiring reviewer for UK engineering roles. The audience is a senior engineer preparing a CV for a test management role. Use UK English. Rely only on the experience listed in the provided notes; do not infer or add employers, dates, or responsibilities that are not explicitly stated.
Example 2: Application Code (Web Utility)
Context: We are building a lightweight, browser-based prompt-builder widget embedded inside a WordPress page. The primary function is letting users fill in structured fields and copy a clean prompt string. Keep the code modular with clean separation between state/formatting logic and DOM rendering so additional modules can be added later without rewriting existing code.
6. Hands-On Exercise
- Pick a real task you want AI to help with this week (either a general task or a small feature/app you want to build).
- Write a Context block using three short lines: Who/What is it for, What facts or scope apply, and What must not be assumed.
- Test it with your AI tool and check: did the model stay within your facts and scope, or did it bring in outside assumptions?
