Key Topics:
Prompt Engineering:
Crafting prompts for specific outputs (e.g., test generation, docstrings, refactor suggestions).
Techniques to refine or guide the AI’s responses (few-shot examples, specifying code style, etc.).
Combining Multiple Assistants/APIs:
Using different tools in parallel or sequentially (Copilot + Tabnine) or incorporating an LLM API (OpenAI, etc.).
Potential synergy vs. confusion or repetitive suggestions.
Documentation-First Workflow (Revisited in Depth):
Using docs, contracts, or interface definitions to drive code generation.
Keeping docs and implementation synced with minimal manual overhead.
Vibe Coding (Revisited in Depth):
Emphasis on flow, iterative exploration with minimal upfront planning.
Rapid prototypes, creative coding, or “hackathon” scenarios.
Below you will find some suggested materials on these topics, which we believe may help you complete the final activity in the lesson. Please note that using these resources is entirely optional, and you are welcome to explore any other sources or courses at your own discretion.
Here are some recommended courses to explore:
Key Topics:
Prompt Engineering:
Crafting prompts for specific outputs (e.g., test generation, docstrings, refactor suggestions).
Techniques to refine or guide the AI’s responses (few-shot examples, specifying code style, etc.).
Experiment with different prompts, temperature settings, and few-shot examples.
Great for rapid iteration to see how changes in prompt wording affect AI output.
Community-generated tips and tutorials on structuring prompts for specific tasks (e.g., generating docstrings).
Often includes code samples to illustrate improvements in output clarity.
Structured lessons covering few-shot prompting, code style constraints, and advanced prompting strategies.
Includes quizzes and hands-on labs to reinforce best practices.
Master the Art of Crafting Prompts to Unlock the Potential of Large Language Models (LLMs) for Developers
Learn practical coding skills for working professionally with AI, including GPT-4, Stable Diffusion, and GitHub Copilot.
Key Topics:
2. Combining Multiple Assistants/APIs:
Using different tools in parallel or sequentially (Copilot + Tabnine) or incorporating an LLM API (OpenAI, etc.).
Potential synergy vs. confusion or repetitive suggestions.
Threads where developers share experiences combining Copilot, Tabnine, or ChatGPT. Focuses on issues like conflicting suggestions and how to unify them productively.
Mastering Multi-Agent Systems for Research Automation and Visualization with AutoGen
Generative AI unlocks a whole new set of next-level functionalities. This course will teach you what you need to know to integrate Gen AI into your application.
In this engaging webinar, Bill Fanning, Deirdre Jennings-Holton, Padma Durvasula, Norman Clausen and other community members explored the evolving landscape of talent acquisition technology and training.
Key Topics:
4. Vibe Coding (Revisited in Depth):
Emphasis on flow, iterative exploration with minimal upfront planning.
Rapid prototypes, creative coding, or “hackathon” scenarios.
Activity:
Write a single, well-structured prompt to generate an entire microservice skeleton (e.g., “Generate a Node.js microservice with an Express server, a /users endpoint, and basic JWT authentication”).
Use your code assistant of choice to handle multiple iterations:
Iteration 1: Basic server + endpoint.
Iteration 2: Add documentation (Swagger/OpenAPI style) driven by the AI.
Iteration 3: Switch to vibe coding style—ask the AI for suggestions on improvements or new endpoints spontaneously.
Goal:
See how prompt engineering, documentation-first, and vibe coding can coexist. Learn to adapt your prompts to each approach.
Set Up Your Environment
Create a folder named microservice-demo.
Open it in your favorite IDE (VS Code, IntelliJ, etc.).
Ensure your code assistant (e.g., GitHub Copilot, Tabnine, or CodeWhisperer) is installed and enabled.
Formulate a Single Prompt (High-Level)
In a file named prompt_instructions.md (or similar), write a well-structured request:
markdown
CopiarEditar
# Generate a Node.js Microservice
**Requirements**:
- Use Express for the server
- Provide a `/users` endpoint (GET or POST)
- Include basic JWT authentication for protected routes
- Use best practices for folder structure
- Prepare for future expansions (services, middlewares, etc.)
Reference this doc (or copy it as a comment in your app.js), so your AI assistant knows your goals.
Iteration 1: Basic Server + Endpoint
Start a new file: app.js (or index.js).
Write an initial comment referencing your prompt:
javascript
CopiarEditar
// Based on prompt_instructions.md, let's set up an Express server
// We'll create a /users endpoint and handle basic server config
Pause to see if your AI assistant suggests boilerplate code (e.g., const express = require('express'); ... app.listen(3000, ...)).
Accept or Refine the code. For example, you might end up with:
javascript
CopiarEditar
const express = require('express');
const app = express();
app.use(express.json());
app.get('/users', (req, res) => {
res.json({ message: 'Users endpoint' });
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
Test by running node app.js and hitting GET /users in Postman or curl:
bash
CopiarEditar
curl http://localhost:3000/users
Iteration 2: Add Documentation (Swagger/OpenAPI Style)
Decide how you want documentation integrated. For example, you might ask:
javascript
CopiarEditar
// I'd like to add Swagger/OpenAPI docs for the /users endpoint.
// Could you generate a basic swagger.yaml or set it up with swagger-ui-express?
Observe the AI’s suggestions:
It may add swagger-ui-express and swagger-jsdoc dependencies.
Or it might generate a swagger.yaml file.
Accept or adapt what it proposes. A typical snippet might look like:
javascript
CopiarEditar
const swaggerUi = require('swagger-ui-express');
const swaggerJsdoc = require('swagger-jsdoc');
const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'My Microservice',
version: '1.0.0'
},
},
apis: ['./app.js'], // or separate files
};
const specs = swaggerJsdoc(options);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
Write or let the AI generate the JSDoc/Swagger comments in app.js, e.g.:
javascript
CopiarEditar
/**
* @openapi
* /users:
* get:
* description: Returns users
* responses:
* 200:
* description: A JSON array of users
*/
app.get('/users', (req, res) => {
res.json([{ id: 1, name: 'Alice' }]);
});
Confirm by running the server and visiting http://localhost:3000/api-docs (or your chosen route). You should see the Swagger UI.
Iteration 3: Switch to Vibe Coding
Now, drop the formal instructions and switch to a vibe coding approach:
javascript
CopiarEditar
// Let's vibe: Maybe we should add a POST /users with JWT authentication.
// We'll store user data in an in-memory array for now.
// Let's see how the AI suggests we handle it.
Type partial logic, see if the AI assistant completes or refines it:
javascript
CopiarEditar
let users = [{ id: 1, name: 'Alice' }];
app.post('/users', (req, res) => {
// ...
});
Add a brief comment about JWT if you want the AI to propose a solution:
javascript
CopiarEditar
// I'd like a simple JWT auth approach.
// Maybe a middleware that checks req.headers.authorization?
Accept or revise the suggestions. The AI might propose using jsonwebtoken, verifying tokens, etc.
Keep “vibing” by spontaneously adding or altering endpoints, letting the AI fill in details.
Test & Validate
Whenever you add or modify an endpoint, do a quick test using Postman or curl.
Double-check the Swagger docs (if you’re referencing them) to ensure they stay in sync. If not, you might do a quick doc fix or prompt the AI to auto-update.
Observe How Each Approach Interacts
Iteration 1 used a single, well-structured prompt to outline the microservice.
Iteration 2 leveraged a doc-driven approach (Swagger/OpenAPI).
Iteration 3 was purely vibe-based, letting you explore spontaneously.
Wrap Up
You’ve now iterated through prompt engineering, documentation-first (via Swagger), and vibe coding in a single microservice.
This trifecta showcases how the AI can adapt to structured specs or spontaneous queries.
Create a set of 3 or 4 prompts that each target different objectives within the same microservice (e.g., “generate unit tests,” “refactor for security,” “create usage documentation in Markdown,” “add a new feature on-the-fly with vibe coding”).
Document (in a PROMPT_LOG.md file):
The exact wording of each prompt.
The AI’s output (code snippets, doc changes, etc.).
Any edits you had to make manually (if the AI missed or misunderstood something).
Push your code to a repo or share a zip, illustrating how each prompt shapes the final codebase.
Objective: Master prompt engineering by systematically testing different prompt types. Learn how to seamlessly shift from a doc-driven approach to vibe coding in real scenarios.
Set Up or Reuse Your Microservice
Open the same microservice or small project from the main lesson.
Make sure your code assistant (Copilot, Tabnine, CodeWhisperer, etc.) is enabled.
Ensure you have a Git repo or a local folder where you can track changes.
Decide on 3 or 4 Objectives
Example objectives:
Generate Unit Tests for a core function or endpoint.
Refactor for Security (like ensuring tokens are handled properly).
Create Usage Documentation in Markdown (doc-driven approach).
Add a New Feature spontaneously with vibe coding.
Write Each Prompt & Observe the AI’s Response
You’ll create 3–4 distinct prompts. For each one:
Prompt #1 (Generate Unit Tests)
In your code or a comment, explicitly prompt the AI:
javascript
CopiarEditar
// Prompt: "Generate Jest unit tests for the 'createUser' function, covering edge cases like missing fields or invalid email."
Accept or refine the snippet. The AI might produce a test file or partial test code.
Prompt #2 (Refactor for Security)
Suppose you have an endpoint that handles user tokens:
javascript
CopiarEditar
// Prompt: "Refactor the /login endpoint to improve security. Ensure we hash the user password and store a short-lived session token."
See how the AI modifies your code. Record any manual fixes if it misuses a library or misses a crucial step.
Prompt #3 (Create Usage Documentation)
Maybe you want a README or DOCS.md:
javascript
CopiarEditar
// Prompt: "Write a Markdown usage guide for the /users and /login endpoints, including sample requests and responses."
The AI might generate an entire doc. Store it or refine it as needed.
Prompt #4 (Add a New Feature on-the-fly with Vibe Coding)
Start a comment:
javascript
CopiarEditar
// Prompt: "Add a /reports endpoint that returns user statistics. Let's do it vibe coding style—no prior docs, just code suggestions."
Accept or iterate on suggestions spontaneously, letting the AI handle structural decisions.
Log Everything in PROMPT_LOG.md
Create a file named PROMPT_LOG.md at your project’s root.
For each prompt, add:
markdown
CopiarEditar
## Prompt #1: Generate Unit Tests
**Exact Wording**:
"Generate Jest unit tests for the 'createUser' function, covering edge cases..."
**AI Output**:
```javascript
// <AI's code snippet or partial suggestions>
Manual Edits:
Rewrote lines 10-15 because the AI used an incorrect syntax for mocking.
Changed test descriptions for clarity.
Prompt #2: Refactor for Security
...
CopiarEditar
Include partial or full code snippets from the AI. This ensures you can track how your final code diverged from the AI’s suggestions.
Incorporate AI’s Output into the Codebase
Actually merge or commit the AI’s changes into your microservice, so you can run or test them.
If a snippet is incomplete, do minimal manual fixes but document them in PROMPT_LOG.md.
Push or Share Your Final Code
Once you’ve integrated all 3–4 prompts, push your changes to Git or zip the folder:
bash
CopiarEditar
git add .
git commit -m "Add AI-driven code via 3 distinct prompts"
git push
Alternatively, create a zip including your code and the PROMPT_LOG.md.
Review & Wrap Up
Check how each prompt changed your code:
Did the test generation produce valid tests with high coverage?
Did the security refactor genuinely improve your endpoint’s safety?
Did the doc generation produce a coherent guide for new devs?
Did the vibe-coded feature come out well, or was it chaotic?