Prompting for Developers: Get 10x More From LLMs

Chain-of-thought, role prompting, few-shot examples, and structured output — developer-specific LLM techniques that actually work.

By Rais Helmy, IT consultant in Kuala Lumpur, Malaysia.

LLM Prompting for Developers. Get 10x more.

Most developers use LLMs like a search engine. The ones shipping 10x faster treat them like a junior developer who needs proper context.

technique 1 · context-first prompting

Expectation: best practice

  • Provide full context: tech stack, constraints, existing patterns, and desired output format.
  • Specify what you do NOT want — "no classes, use only arrow functions, no lodash".
  • Include an example of the style or pattern you expect.

Reality: what most teams do

  • "Write me a login function" — vague prompt, generic output, rounds of correction.
  • No mention of language version, framework version, or constraints.
  • Asking for code without telling it how the rest of the codebase looks.

Better approach (code)

// ✦ Context-rich prompt
You are a senior TypeScript developer.
Stack: Next.js 14, Prisma, PostgreSQL.
Style: arrow functions, no classes, zod validation.

Write a server action that:
- Accepts FormData
- Validates with zod schema (email + password)
- Calls prisma.user.create()
- Returns { success, error } — never throws

Common mistake (code)

// ✗ Vague prompt
Write me a user registration function in TypeScript

// Result: generic Express handler with bcrypt,
// no zod, classes, no error handling pattern,
// completely different from your actual codebase style

technique 2 · chain-of-thought + role prompting

Expectation: best practice

  • "Think step by step" or "reason before answering" dramatically improves accuracy on complex problems.
  • Role prompting: "Act as a security engineer reviewing this code for OWASP Top 10 issues."
  • Separate reasoning from action: "First explain the bug, then provide the fix."

Reality: what most teams do

  • Accepting the first answer without asking for reasoning — misses edge cases.
  • Single-turn prompts for multi-step architectural decisions.
  • "Fix this" without specifying what correct looks like — gets you something different, not necessarily better.

Example (code)

// ✦ Chain-of-thought for debugging
This function returns undefined sometimes.
Think step by step:
1. Identify all code paths that could return undefined
2. Explain which input causes this
3. Provide a fix with proper null handling
4. Add a unit test for the edge case

Code:
[paste code here]

// ✦ Role prompting for security review
Act as a security engineer doing a code review.
Check for: SQL injection, XSS, IDOR, broken auth.
For each issue: severity + line number + fix.

[paste endpoint code]

Ask for the shape you need, not just the content.

LLMs will match whatever format you demonstrate. If you need JSON, show the schema. If you need a PR description, show the template. If you need test cases, show the test structure. The model will follow your pattern.

Unstructured (bad)

"List the edge cases for this function" → prose paragraph you have to manually parse into test cases

Structured (good)

"List edge cases as JSON: [{input, expected, reason}]" → paste directly into parameterized tests

→ Pro tip: End prompts with "Output only the code/JSON/list — no explanation" to skip verbose preambles when you just need the artifact.

prompting techniques by use case

  • Debug a bug: Chain-of-thought - "Think step by step, identify all paths"
  • Code review: Role prompting - "Act as a senior security engineer"
  • Architecture: Few-shot examples - Show 1–2 patterns you like, ask to extend
  • Test writing: Structured output - "Return as [{input, expected, reason}]"
  • Refactoring: Constraint prompt - "No classes, preserve behaviour, add types"
  • Risky prompts: Add constraints - "Explain trade-offs before changing anything"