Guia Resumido de Prompt Engineering + Exemplos Práticos
Prompt Engineering é a prática de orientar modelos de IA para gerar
respostas consistentes, úteis e alinhadas ao objetivo desejado. Ele é
aplicado em documentação, implementação, code review, brainstormings e
automações.
1. Principais Categorias de Uso
Documentações
- Requisitos, user stories, tasks\
- Desenho e arquitetura (C4, system design)\
- ADRs, RFCs\
- Padrões técnicos: code review, testing, guidelines\
- Runbooks, playbooks, post-mortems
Implementação
- Criação de tarefas\
- Fluxos e workflows\
- Testes, debugging\
- Refactoring\
- Commits e Pull Requests
Code Review
- Verificar funcionalidades\
- Testabilidade, cobertura\
- Bugs e inconsistências\
- Padrões de código
2. Técnicas de Prompt Engineering
Zero-Shot → Tarefa direta, sem exemplos
O que é
Modelo recebe apenas a instrução.
Quando usar
- Perguntas simples\
- Tarefas bem conhecidas\
- Baixo custo de tokens
Como usar
Dê instruções claras e diretas.
Exemplos
Simples: "Explique em tópicos as diferenças entre goroutine e
thread."
Avançado: "Explique o GC do Go em menos de 5 tópicos, focando em
performance."
One-Shot / Few-Shot → Demonstre o padrão desejado
O que é
Forneça exemplos para guiar o modelo.
Exemplos
Simples: Gerar documentação seguindo um exemplo.
Avançado: Gerar Pull Request seguindo um template fixo.
Chain of Thought (CoT) → Raciocínio passo a passo
O que é
O modelo pensa em etapas antes de responder.
Exemplos
Simples: Explicar panic em slice vazio.
Avançado: Analisar concorrência em consumo Kafka.
Skeleton of Thought (SoT) → Estrutura fixa
O que é
Resposta obrigatoriamente organizada por tópicos.
Exemplos
Simples: Explicar gRPC em tópicos.
Avançado: Documentar arquitetura de rate limiting com seções
definidas.
Tree of Thought (ToT) → Múltiplas alternativas
O que é
Explorar caminhos diferentes antes de decidir.
Exemplos
Simples: 3 formas de fazer cache em Go.
Avançado: 3 arquiteturas para 200k req/s com decisão final.
Self-Consistency → Várias execuções para escolher a melhor
O que é
O modelo gera diversas respostas e escolhe a mais consistente.
Exemplos
Simples: 5 cálculos de custo AWS.
Avançado: 7 cálculos de shards para banco multitenant.
Directed Prompting → Controle do estilo e formato
O que é
Comandos como "Liste", "Compare", "Explique", "Responda em JSON".
Exemplos
Simples: "Liste motivos de memory leak em Go."
Avançado: Comparar Redis, Memcached e Hazelcast.
ReAct → Raciocínio + ações externas
O que é
O modelo segue: Thought → Action → Observation → Final Answer.
Exemplos
Simples: Inspeção de logs do Docker simulada.
Avançado: Diagnóstico completo de falha de container em produção.
3. Cheat Sheet → Como escolher rapidamente?
| Objetivo | Técnica ideal |
|---|
| Resposta rápida | Zero-Shot |
| Repetir estilo | Few-Shot |
| Raciocínio profundo | CoT |
| Estrutura organizada | SoT |
| Alternativas | ToT |
| Maior confiabilidade | Self-Consistency |
| Controle de saída | Directed Prompt |
| Ações externas | ReAct |
Conclusão
Cada técnica tem seu propósito:
- Zero-Shot → rápido\
- Few-Shot → padronização\
- CoT → raciocínio profundo\
- SoT → organização\
- ToT → exploração\
- Self-Consistency → robustez\
- Directed Prompt → controle\
- ReAct → automação e agentes
Este guia ajuda desenvolvedores a criar prompts mais eficientes,
previsíveis e úteis no dia a dia.
Prompt Engineering Guide + Practical Examples
Prompt Engineering is the practice of guiding AI models to produce
consistent, useful, and objective‑aligned responses. It is applied in
documentation, implementation, code review, brainstorming, and
automation.
1. Main Usage Categories
Documentation
- Requirements, user stories, tasks\
- Architecture (C4, system design)\
- ADRs, RFCs\
- Technical standards: code review, testing, guidelines\
- Runbooks, playbooks, post‑mortems
Implementation
- Task creation\
- Workflows and flows\
- Testing, debugging\
- Refactoring\
- Commits and Pull Requests
Code Review
- Feature validation\
- Testability and coverage\
- Bug identification\
- Code standards
2. Prompt Engineering Techniques
Zero‑Shot → Direct task, no examples
What it is
The model receives only the instruction.
When to use
- Simple questions\
- Well‑known tasks\
- Low token usage
Example prompts
- "Explain the differences between goroutines and threads in bullet
points."\
- "Summarize Go's garbage collector in 5 points."
One‑Shot / Few‑Shot → Demonstrate the pattern
What it is
Provide 1--5 examples so the model learns from them.
Example prompts
- Generate documentation following a given example.\
- Write a Pull Request using a predefined template.
Chain of Thought (CoT) → Step‑by‑step reasoning
What it is
The model explains reasoning before the final answer.
Example prompts
- Explain step by step why a slice access causes a panic.\
- Analyze concurrency issues in a Kafka consumer service.
Skeleton of Thought (SoT) → Structured response
What it is
The model must follow predefined sections.
Example prompts
- Explain gRPC using: what it is, when to use, advantages,
disadvantages.\
- Document a rate limiting architecture using structured sections.
Tree of Thought (ToT) → Multiple reasoning paths
What it is
The model explores different alternatives before deciding.
Example prompts
- Provide 3 approaches to caching in Go + choose the best.\
- Provide 3 architectures for handling 200k req/s.
Self‑Consistency → Multiple outputs → choose the best
What it is
The model generates several responses and selects the most consistent.
Example prompts
- Generate 5 cost calculations for AWS infrastructure.\
- Produce 7 shard estimations for a multitenant database.
Directed Prompting → Control over style and format
What it is
Commands such as "List", "Compare", "Explain", "Respond in JSON".
Example prompts
- "List main causes of memory leaks in Go."\
- Compare Redis, Memcached, and Hazelcast using specific criteria.
ReAct → Reasoning + external actions
What it is
Structure: Thought → Action → Observation → Final Answer.
Example prompts
- Simulate Docker log inspection.\
- Diagnose a failing container after deploy.
3. Cheat Sheet → Quick Selection
| Goal | Best Technique |
|---|
| Fast response | Zero‑Shot |
| Repeat a style | Few‑Shot |
| Deep reasoning | CoT |
| Structured content | SoT |
| Explore alternatives | ToT |
| Highest reliability | Self‑Consistency |
| Output formatting | Directed Prompt |
| External actions | ReAct |
Conclusion
Each technique has a purpose:
- Zero‑Shot → fast\
- Few‑Shot → style and consistency\
- CoT → deep reasoning\
- SoT → structured organization\
- ToT → alternative exploration\
- Self‑Consistency → higher reliability\
- Directed Prompt → format control\
- ReAct → automation and agents
This guide helps developers produce clearer, more consistent, and more
effective prompts for everyday AI usage.