👯‍♀️

domain specific prompting

AI can do a lot of things, and you may want to tailor your prompt to meet the needs and conventions of each discipline, whether you’re writing code, conducting research, crafting creative content or performing data analysis.

Below are four recipes, each with examples:

Coding prompts

Key goals: Correctness, readability, testability, performance.

How to Structure:

  1. Role and context: “You are a senior software engineer.”
  2. Task description: “Write a Python function that…”
  3. Input/output spec: Clearly define parameters and return types.
  4. Constraints: Time/space complexity, version requirements, library restrictions.
  5. Testing: Ask for example calls or unit tests.
  6. Comments and style: Specify idiomatic style or docstring format.

Example:

You’re a Python expert. Task: Implement `def normalize_text(s: str) -> str` that lowercases, strips punctuation, and collapses whitespace. Constraints: O(n) time, no external libraries. Include: - Docstring following Google style. - Three pytest unit tests covering edge cases.

Research prompt

Key goals: Accuracy, breadth, critical insight, citations.

How to structure:

  1. Role and depth: “You’re an academic researcher in renewable energy.”
  2. Scope: Specify date range, geographic focus, or subfield.
  3. Format: Ask for an executive summary, bullet points, or comparative table.
  4. Sources and citations: Request APA/MLA citations or URLs.
  5. Critical lens: Ask to identify gaps, biases, or future directions.

Template:

You’re an environmental economist. Prompt: Summarise the top five peer-reviewed studies (2018–2024) on offshore wind cost trends. Deliver: - 200-word executive summary - A table with study name, region, levelized cost (USD/MWh) - APA-style citations - Two open research questions.

Creative prompts

Key goals: Originality, voice consistency, emotional impact.

How to structure:

  1. Role and tone: “Act as a horror novelist.”
  2. Setting and characters: Provide minimal prompts and let the model fill in details.
  3. Plot beats: Ask for inciting incident, rising action, climax.
  4. Stylistic constraints: Word count, point of view, sensory details.
  5. Revision steps: “Then rewrite with more tension,” or “Provide three alternative endings.”

Template: You’re a YA fantasy author. Task: Write a 300-word scene in second person where the hero first discovers their magic. Include: vivid sensory details, internal monologue, and one surprising twist. Afterwards, rewrite the opening sentence for greater suspense.

Analytical prompts

Key goals: Structure, rigor, clarity, actionable insights.

How to structure:

  1. Role and dataset: “You’re a business analyst given this monthly sales table.”
  2. Objective: “Identify underperforming regions and recommend three growth strategies.”
  3. Output format: Bulleted recommendations, ranked list, or annotated chart instructions.
  4. Metrics & KPIs: Specify which ratios or trends to calculate.
  5. Visualisation guidance: “Suggest the ideal chart type for each insight.”

Template:

You’re a data analyst. Input: CSV with columns [Region, Month, Revenue, Cost]. Task: 1. Compute profit margin by region. 2. Flag regions below 10%. 3. Recommend three tactics to boost margins (one operational, one marketing, one pricing). 4. Suggest which chart (bar, line, heatmap) best showcases each insight.

And obviously, you can extend this to any domain.. the key here is to:

  • Be explicit: The more you define role, format, and constraints, the less “hallucination.”
  • Use examples: Few shot examples in your domain help models internalise conventions.
  • Iterate and refine: Test your prompt, review output, then tweak context or constraints.
  • Combine patterns: Wrap domain prompts in chain of-thought or meta cognitive scaffolds for deeper reasoning.

Conclusion

By speaking the model’s “domain dialect,” you’ll get answers that are precise, relevant, and immediately actionable no matter the field.