← Back to course

Prompt Engineering aplicado a Dev

Prompt Engineering Dev

prompt.png

🧠 Lesson: Prompt Engineering for Developers (AI-Native)

🎯 Objective

Learn how to design, structure, and optimize prompts to build real software faster using AI—across frontend, backend, testing, and deployment.


🚀 1. What is Prompt Engineering (in Development)?

Prompt engineering is the skill of communicating with AI to produce reliable, production-ready outputs.

👉 For developers, this means:

  • Generating clean code

  • Designing architectures

  • Writing tests

  • Debugging faster

  • Automating workflows

You are not just coding—you are orchestrating AI to code with you.


🧠 2. The Core Principle

Bad prompt → random output
Good prompt → structured, usable solution

👉 The quality of your prompt = the quality of your system


🧩 3. The Developer Prompt Framework

Use this structure for almost everything:

🧱

1. Role

Tell the AI who it is

“You are a senior full-stack developer using React and NestJS”


📌

2. Context

Provide system details

Stack, architecture, constraints, business goal


🎯

3. Task

Be explicit

“Create a login API with JWT authentication”


📋

4. Constraints

Define rules

  • Use TypeScript

  • Follow clean architecture

  • Use DTOs and validation


📤

5. Output Format

Control the response

“Return code only, separated by files”


✅ Example (GOOD prompt)

You are a senior NestJS developer.

Context:
I am building a SaaS application with authentication.

Task:
Create a login endpoint using JWT.

Constraints:
- Use NestJS best practices
- Use DTO validation
- Include error handling

Output:
Return the controller, service, and DTO files separately.

⚙️ 4. Prompting Across the Dev Workflow

💻 1. Code Generation

  • Components (React)

  • APIs (NestJS)

  • Database schemas

👉 Tip: Always specify structure + patterns


🧪 2. Testing (TDD + E2E)

Prompt example:

“Generate unit tests for this service using Jest, covering edge cases”

👉 AI can:

  • Create tests

  • Suggest missing cases

  • Improve coverage


🐛 3. Debugging

Prompt example:

“Explain why this code fails and suggest a fix with minimal changes”

👉 Add:

  • Error logs

  • Stack traces

  • Code snippet


🔁 4. Refactoring

Prompt example:

“Refactor this code to follow clean architecture and improve readability”


📦 5. Architecture Design

Prompt example:

“Design a scalable architecture for a multi-tenant SaaS using NestJS and PostgreSQL”


🧠 5. Advanced Prompting Techniques

🔁 Iterative Prompting

Don’t expect perfection in one shot:

  1. Generate

  2. Review

  3. Refine

  4. Improve


🧩 Chain of Thought (Guided Thinking)

Ask AI to reason step-by-step:

“Explain your approach before writing the code”


🧠 Context Injection

Provide:

  • Existing code

  • Project structure

  • Business rules

👉 More context = better output


🎭 Role-Based Prompting

Assign expertise:

  • “Senior frontend engineer”

  • “DevOps expert”

  • “QA engineer”


🧰 6. Tools That Amplify Prompt Engineering

💻 Development

  • AI copilots (IDE integration)

  • Chat-based coding assistants

🎥 Content / Product

  • ElevenLabs

  • HeyGen

  • Nano Banana

👉 Prompt engineering applies beyond code → also marketing, demos, and content


⚠️ 7. Common Mistakes

  • ❌ Vague prompts → “Create an app”

  • ❌ No constraints → messy code

  • ❌ No output format → unusable results

  • ❌ Blind trust in AI

  • ❌ No iteration


🧪 8. Practical Exercise

🛠️ Task:

Build a feature using prompts only

Feature: User registration

  1. Prompt AI to generate:

    • Backend API (NestJS)

    • Frontend form (React)

    • Validation

    • Tests

  2. Improve your prompts until:

    • Code is clean

    • Works correctly

    • Follows best practices

  3. Compare:

    • First prompt vs final prompt


🧩 9. Prompt Templates (Reusable)

🔹 Generate API
You are a senior backend developer.

Create a [feature] using NestJS.

Constraints:
- Use TypeScript
- Follow clean architecture
- Include validation and error handling

Output:
Return code separated by files.

🔹 Generate Tests

You are a QA engineer.

Generate unit tests for this code.

Constraints:
- Use Jest
- Cover edge cases
- Mock dependencies

🔹 Debug Code

You are a senior developer.

Analyze the following code and error.

Explain the issue and provide a fix.