Clinical Context Engineering
Adapted for NHS/Healthcare from the GOV.UK Context Engineering Playbook.
AI coding assistants are only as good as the context they receive. Prompt engineering is simply asking a question. Context engineering is deliberately structuring the AI's environment so that it generates inherently safe, compliant, and clinically accurate code without you having to remind it every single time.
Why Context Matters in Healthcareβ
If you ask an AI, "Write me a patient intake form," it will guess what to build based on the generic internet. It might use American drug names, store data insecurely, and ignore accessibility laws.
Through context engineering, the AI already knows before you even ask that:
- It must use the NHS Dictionary of Medicines and Devices (dm+d).
- It must pass the Web Content Accessibility Guidelines (WCAG) 2.2 AA.
- It must never log Personally Identifiable Information (PII).
The Context Hierarchyβ
Strategies for Nurse Citizen Developersβ
1. The Global Instruction File (.cursorrules or CLAUDE.md)β
In modern AI IDEs (like Cursor or Claude Code), you can place a hidden file in your project's root directory that acts as the "Commandments" for the AI. Every time it writes code, it reads this file first.
Example CLAUDE.md for a Clinical App:
# AI Context for NHS Handover Tool
## Important Conventions
- Always use British English (e.g., 'paediatric', 'haemorrhage').
- Use ISO 8601 dates (YYYY-MM-DD).
- Medical terminology must align with SNOMED CT UK Edition.
## Security & Compliance (CRITICAL)
- NEVER log Personally Identifiable Information (PII) to the console.
- Strip all NHS numbers and patient names before sending data to external APIs.
- Adhere to the NHS Data Security and Protection Toolkit (DSPT) principles.
## Architecture
- Use React for the frontend with strict accessibility testing (WCAG 2.2).
- Backend must use parameterized SQL queries to prevent injection attacks.
2. Constraint-Driven Promptingβ
Specify exactly what the AI cannot do. This is crucial for avoiding hallucinated APIs or dangerous clinical assumptions.
Better Prompting Example:
Refactor this triage function to improve performance.
Constraints:
- DO NOT change the core clinical scoring logic.
- DO NOT add external package dependencies without asking.
- Must maintain backward compatibility with legacy generic patient records.
3. Progressive Disclosure for Complex Clinical Logicβ
Do not dump a massive, complex clinical algorithm (like a massive NEWS2 scoring chart) into the AI all at once. Start high-level and drill down.
- Prompt 1: "Here is the summary of the NEWS2 scoring system. Do you understand the parameters?"
- Prompt 2: "Good. Now here is the Respiratory Rate segment. Implement a TypeScript function just for this."
- Prompt 3: "Now implement the Temperature segment, following the exact same error-handling pattern you used for Respiratory Rate."