Podcast Title

Author Name

0:00
0:00
Album Art

4 AI Prompting Strategies to Supercharge Your Development Workflow

By 10xdev team July 28, 2025

In this article, I'm going to give you four prompts and prompt strategies that you can use as a developer to get an AI to work really hard for you. Even if you're not a developer, I think you'll like this article. You can use these strategies no matter what you're doing.

OK, let's go.

4. The Q&A Strategy Prompt

This is where you get the AI to prompt you so that you can prompt the AI. It sounds weird, but check it out. I've got a small dashboard project here that is rapidly growing, and currently, all of the files are just kind of in here together. It's like a junk drawer:

/
├── app.js
├── db.js
├── service.js
└── template.pug

So, I'm going to ask the AI to propose a folder structure for this project that's going to help me organize this thing correctly. I'm also going to mention my workspace when I do that, and this passes information about my current project along with this prompt. But instead of just stopping there, I'm going to ask the AI to ask me some yes/no questions to help it provide a better recommendation.

Propose a folder structure for this project. Ask me yes/no questions to provide a better recommendation.

OK, let's see what it's asking for here and answer each one of these. I'm just going to provide the question number and a simple answer to do that.

  1. AI: Does this project expose a RESTful API? Me: Yes.
  2. AI: Is there any user authentication or authorization involved? Me: Yes.
  3. AI: Are you planning to use microservices? Me: No.
  4. AI: Will the application serve static files (e.g., CSS, client-side JS)? Me: Yes.
  5. AI: Do you have separate environments (e.g., development, testing, production)? Me: Yes.

Now, notice at number six, it starts to veer away from simple yes or no. And by #10, it's not even a yes/no question at all. But that's OK. This is the nature of AI. We'll just work with it and provide very short answers, and then we get a nice recommendation for how to structure this project.

The magic of the Q&A prompt is that it helps you put all of the details in the prompt that you would have put there in the beginning if only you'd thought of them. So don't try and write the perfect prompt the first time. Use the Q&A strategy to help the model prompt you to give it the best prompt.

3. The Pros and Cons Prompt

In programming, there is rarely a single right way to do anything, despite the blog post that you read last week telling you otherwise. I've implemented a bit of the model's suggestions on how to structure my project now. I've got an api folder, a views folder, and a db folder. But for the db/Connection.js class here, I've written the connection, but I'm not 100% sure if this is really the best way to do this for this app.

// db/Connection.js
class Connection {
  constructor() {
    // Connection logic here
  }
  query(sql) {
    // Query logic here
  }
}

So, I'm going to ask the model for suggestions on different ways I could implement this database connection logic, and I'm going to ask it for the pros and cons of each suggestion. I'm also going to mention the file directly so that the prompt sends the code that I want the model to review.

What are some different ways I could implement this database connection logic? Give me the pros and cons of each suggestion.

OK, so let's see.

  1. Singleton Pattern:
    • Pros: Ensures only one database connection is ever created, saving resources.
    • Cons: Can be inflexible if you need to connect to other data sources.
  2. Instance per Request (Current Method):
    • Pros: Simple to understand and implement.
    • Cons: Possible connection leaks if not managed carefully.
  3. Connection Pooling:
    • Pros: Highly performant for applications with many concurrent users.
    • Cons: Can lead to resource exhaustion if the pool size is not configured correctly.
  4. Async/Await Refactor:
    • Pros: This isn't a new pattern, but using modern async/await will make the existing code cleaner and less prone to callback issues.
    • Cons: Doesn't solve the underlying architectural choice.
  5. ORM (Object-Relational Mapper):
    • Pros: Abstracts away raw SQL, can speed up development.
    • Cons: Adds another layer of abstraction, can be overkill for simple projects.

OK, so let's pick the singleton. I'm going to ask it to rewrite this code in that pattern.

Rewrite this code to use the Singleton pattern.

And then I could just ask how I would use this in the app.

How would I use this in the app?

OK, so it looks like we just import it and then call the getInstance and then query it.

import Connection from './db/Connection.js';

const db = Connection.getInstance();
db.query('SELECT * FROM users');

Nice. Easy peasy. Remember, there's no one right way to do anything in programming, so use a pros and cons prompt and have the model give you several options so you can pick the best one for you.

2. The Stepwise Chain of Thought Prompt

Chain of Thought just means that you ask the model to break things up into steps and go one step at a time. For instance, this code file could stand to be refactored and cleaned up, but there's a lot of work to be done here. So let's ask the AI to help us refactor it.

Refactor this file.

So we get back a kind of verbose response. It is moving one step at a time, but it's trying to do the entire refactor in one shot. It's just too many changes for us to validate at one time. Let's try this again.

This time, I'm going to tell the AI to move one step at a time but to wait for the keyword "next" before proceeding. This magic keyword is what's going to make the AI only do one thing at a time.

Refactor this file. Go one step at a time, and wait for me to say "next" before proceeding.

First, it wants us to stop using var, which, sure, fine. I'm not going to touch that yet because I want to refactor the db connection variable itself. And if we do "next" here, it does that. OK, perfect. And then we can apply the changes.

Sometimes when you do this, you'll want to ask questions about a particular step to get clarification. For example, it wants me to add a Vehicle interface here, but I'm thinking this would be better as a separate model class. So let me ask about that.

Wouldn't this be better as a separate model class?

Yeah, see, it kind of agrees with me. You have to be careful about this because the AI will almost always agree with you if you insist that something is the right way to do something. But when you do that, you get out of the flow of waiting for "next." So to fix that, I'm going to go back into the chat and just delete that item from the history so that I can then proceed with "next." Although, apparently, it refuses to move on until I make the vehicle parameter an object. Fine, fine, I can take a hint.

1. The Role Prompt

This is where we're going to depart from our vehicle dashboard and learn a new trick. Literally. AIs love to be given a role to play in a conversation. You can basically tell them what they're good at, and then they're magically good at that thing. It's incredible.

So, I'm going to ask the model to play the role of a teacher. I'm going to tell it that they are excellent at making complex topics simple, and I like to learn by doing. So I'm going to tell the AI that it's good at doing that too.

You are an expert teacher, skilled at making complex topics simple and fun. You believe in learning by doing. We are going to learn Regular Expressions. Go one step at a time, and wait for me to answer before moving on to the next concept. If I get the answer wrong, don't just give me the right answer; nudge me in the right direction so that I can figure it out myself.

And what are we going to learn today, class? Regular Expressions!

AI: OK, let's start with the basics. How would you match the exact word "cat"?

You can match characters just by putting them in a sequence. OK, so it's literally just cat.

Me: cat

AI: Correct! Now, how would you match any three-letter word that starts with 'c' and ends with 't'? The . character is used to match any single character.

I guess that's just c.t.

Me: c.t

AI: Holy crap, you're an expert! OK, one more. How would you match "cat" or "cot" but not "cut"? Use square brackets [] to match any single character from a set.

So like this: c[ao]t. Oh, I got that one wrong. I like how the model calls this a "misunderstanding," like maybe this is both of our faults. Oh, I see, brackets match individual characters. OK, so if we put the 'a' and the 'o' in the brackets, yes.

Me: c[ao]t

AI: Exactly! You're a regex pro already.

You can use this to create a custom curriculum to learn anything at all. AIs love to role-play.

OK, so:

  • Q&A Prompt
  • Pros and Cons
  • Stepwise Chain of Thought
  • The Role Prompt

Remember these prompts and work smarter, not harder, with your AI. Working harder is the AI's job. As always, happy smart coding.

Join the 10xdev Community

Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.

Recommended For You

Up Next