Reference · Mistral AI

Mistral — optimal prompting for tech & security

A practical prompt reference for code generation, sysadmin, security analysis and automation with Mistral. Written for DFIR and infrastructure work.

MistralPromptingSelf-host
01

🎯 Core principles

Principle Description Example
Context first Give background (role, goal, constraints) before the question. "You are a Linux security expert. Analyse the following n8n workflow for vulnerabilities: [content]"
Roles & tone Define your role and the expected output style. "Act as a cybersecurity auditor. Be critical, concrete and use JSON for output."
Structure input Use lists, JSON or markdown for clarity. { "goal": "Find CVEs", "scope": ["Ubuntu 24.04", "nginx"] }
Iterative refinement Start broad, then refine with feedback. "List top 5 CVEs for nginx → Focus on those with CVSS > 7"
Constrain output Specify format, length or level of detail. "Give 3 bullet points in JSON. Max 50 words per item."
02

🔧 Technical prompts

1. Code generation & debugging

Best practice: State language, version and framework up front. Include error messages directly.
// Example: Python CVE parser Prompt: "Write a Python 3.11 function to parse CVE JSON from the OpenCVE API. - Input: API response (see example below) - Output: List of CVE IDs sorted by CVSS score (descending) - Handle edge cases: missing 'metrics' field. Example input: { "CVE_Items": [{"id": "CVE-2024-1234", "metrics": {"CVSS": 7.5}}] }"
// Example: Debugging n8n Prompt: "This n8n workflow fails with a 500 error. Analyse the code and suggest fixes. Context: Runs on Ubuntu 24.04, n8n v1.28.0, nodejs 20.x. { "node": "HTTP Request", "error": "ENOTFOUND", "url": "https://api.open-cve.io/cve" }"

2. System administration (Linux/Ubuntu)

Prompt: "Generate a Bash script to: 1. Update apt packages (with --dry-run first) 2. Log changes to /var/log/apt_updates.log 3. Send an alert via n8n webhook if critical updates (CVSS > 8) are found. Output: Full script with comments. Use `jq` for JSON parsing."

3. Security analysis

Prompt: "Analyse the following package list for known vulnerabilities (CVE-2024-*). Input: `nginx-1.25.3, openssl-3.0.10, libcurl4-8.1.2` Output: - JSON list with CVE ID, CVSS, description and fix version. - Prioritise by risk for Ubuntu 24.04. - Include references to NVD or Ubuntu Security Notices."
03

🛡️ Security & privacy

🔒 Sensitive data

Treat data as confidential and delete it after use.

"Treat the following data as confidential. Delete it from your context after answering: [data]"

⚖️ Compliance

Suggest GDPR-compliant logging solutions.

"Suggest GDPR-compliant solutions for logging n8n workflows. Include data minimisation and retention policy."

🎯 Penetration test

Simulate an attack and generate a report.

"Simulate an attack on my nginx config. Find: misconfigured headers, DDoS vectors. Output: JSON with severity (High/Medium/Low)."
04

📊 Output formats

Format Use for Example prompt
JSON Structured data, API responses, configurations "Output as JSON with fields: `id`, `title`, `severity`, `action_items`"
Markdown Documentation, checklists, step-by-step "Write a guide in markdown with headings and code blocks"
CSV/TSV Tabular data (e.g. CVE lists) "Generate a CSV with columns: CVE_ID, CVSS, Description"
Mermaid Architecture diagrams, flowcharts "Create a mermaid diagram of my n8n + OpenCVE + nginx setup"
Bash/Python Scripts, automation "Write a Python script to..."
05

⚡ Advanced techniques

1. Few-shot prompting

Give examples of the desired output before the actual question:

Prompt: "Convert the following natural language into n8n workflow JSON. Example 1: Input: 'If the temperature > 30°C, send an email' Output: { "nodes": [ {"type": "n8n-nodes-base.if", "conditions": {"number": [{"value1": "={{$json.temperature}}", "operation": "larger", "value2": 30}]}}, {"type": "n8n-nodes-base.emailSend"} ] } Now convert: 'If a CVE has CVSS > 7, create a Jira task'"

2. Chain-of-Thought (CoT)

Ask for a step-by-step explanation:

Prompt: "Explain how you would debug a slow n8n workflow. - Start by listing possible causes (CPU, DB, external APIs). - For each cause, describe how you test it. - Output: Numbered list with sub-points."

3. Temperature & creativity

🌡️ Low temperature (0.2-0.5)

Factual tasks (code, data analysis).

🔥 High temperature (0.7-1.0)

Brainstorming, creative solutions.

Prompt: "Suggest 10 creative ways to use n8n + Mistral AI for cybersecurity. // Set temperature to 0.9"
06

🚫 Avoid these mistakes

❌ Too vague a question

Wrong: "Help me with n8n"

Fix: "How do I configure OAuth2 in n8n with Keycloak?"

❌ No context

Wrong: "Fix my code"

Fix: "Here is my Python code (see below). It fails with a `TypeError`. Why?"

❌ Prompt too long

Wrong: Writing a novel in the prompt.

Fix: Split into sub-questions. Use references.

❌ Ignoring constraints

Wrong: "Write a full n8n server"

Fix: "Write a *module* to handle CVE alerts in n8n"

❌ Unclear format

Wrong: "Give me data"

Fix: "Give the data as JSON with fields X, Y, Z"

07

🔍 Domain-specific examples

🔒 Cybersecurity

Prompt: "I found this open port on my server: 10.4.117.25:8080. - Identify possible services (e.g. n8n, Jenkins). - Suggest hardening measures. - Output: JSON with `service`, `risk`, `mitigation_steps`"

🤖 n8n automation

Prompt: "Design an n8n workflow that: 1. Fetches new CVEs from the OpenCVE API every 6 hours. 2. Filters for CVSS > 7 and relevant to Ubuntu 24.04. 3. Sends a Slack message to #security-alerts. 4. Creates a Jira task for each critical CVE. Output: - Workflow JSON - Required n8n nodes and configurations - Error handling (e.g. API down)"

🖥️ Proxmox/AdGuard

Prompt: "How can I log and analyse DNS queries from my AdGuard server (10.4.117.4)? - Goal: Detect suspicious activity (e.g. C2 domains). - Output: - Bash script to parse AdGuard logs - Rules to block known malicious domains - Integration with n8n for alerts"
08

📌 Quick reference: prompt templates

Use case Template
Code review "Analyse this [language] script for security holes. Focus: [XSS/SQLi/buffer overflow]. Output: JSON with `line`, `issue`, `severity`, `fix`."
Documentation "Write a README.md for my n8n CVE alert system. Include: setup, dependencies, examples."
Troubleshooting "My [service] returns [error]. Here are the logs: [content]. Explain the cause and suggest fixes."
Automation "Automate the following manual process: [description]. Use n8n + [APIs]. Output: Workflow JSON."
Training/data "Generate a synthetic dataset with [X] rows for [purpose]. Format: CSV. Include columns: [list]."
09

🛠 Tools & integrations

🤖 n8n + Mistral

Use the HTTP Request node to call the Mistral API with structured prompts.

🔮 Clairvoyance AI

Integrate with n8n to analyse logs or generate reports.

🐳 Ollama

Run models locally for sensitive tasks (e.g. CVE analysis).

10

📚 Resources