A better way to work with Agent: plan first, then code

In a couple of other posts/comments I’ve been trying to explain my alternative way of working with Agent.

So rather than just tell it “do X, Y and Z” and then cross my fingers that it gets the work right, I first discuss and plan the required work with agent, and only give it the go ahead once I like its plan. This may take 1 prompt or it could be several - there is no rush, as we must ensure we both agree on the work.

I thought it was worth giving an example of this, to get my workflow process across. I welcome feedback:

My first prompt:

Standard rule (no need to tell me you understand this rule each time): Think about the following and discuss with me first. Research and investigate as you need. Do not make any changes until I confirm. If you have conflicting rules that say you must implement solutions, then ensure this instruction overrides and you do not make changes until I give the go-ahead:

  • Thanks for analysing how the signup process works in the code, I now understand it clearly. I guess we use the Supabase auth metadata as a temporary store of initial signup values, and then ignore them after that, and do not try to keep them updated. And the single source of truth for our metadata becomes the users table?

So, now we’ve got that understanding sorted, give me the proposed plan:

  • the signup page has 2 confirm password fields. we need to remove one
  • we need to add a company name field (optional) to signup page. And temporarily store it in the auth table, along with other metadate like first name, last name, user type, industry id and role id
  • we need to add company name to the users DB table. provide me with the SQL in a new script in the gipity-sql-scripts folder so I can modify the users table schema
  • ensure all various API endpoints are updated to supported these additional fields, and plan any other similar changes needed

Agent response:

Perfect! You’re correct about the architecture:

Auth Metadata = Temporary Storage Only

  • Used during signup → email confirmation flow
  • Cleared after user record is created in users table
  • Never updated again after that point

Users Table = Single Source of Truth

  • All user data lives here after email confirmation
  • All updates/queries use this table
  • Auth table only used for authentication

Let me investigate the current signup form and plan the changes:

Executed find ./gipity-sql-scripts -name “*.sql” | head -5

Opened shared/schema.ts

Let me continue investigating the signup form and look for the duplicate password fields:

Opened client/src/pages/Signup.tsx

Executed grep -n -A5 -B5 “password|Password” ./client/src/pages/Signup.tsx

Perfect! Now I can see the issue and plan the changes:

Current Signup Form Analysis

Duplicate Password Fields Found:

  • Lines 203-213: First “Password” field
  • Lines 216-226: “Confirm Password” field
  • Lines 276-286: DUPLICATE “Confirm Password” field ← This is the one to remove

Current Fields: email, password, confirmPassword, firstName, lastName, userType, industryId, roleId

Planned Changes Summary

  1. Frontend Changes (Signup.tsx)
  • Remove duplicate confirm password field (lines 276-286)
  • Add company name field (optional)
  • Update form state to include companyName
  • Update validation and form submission
  1. Schema Changes (shared/schema.ts)
  • Add company_name field to userSchema
  • Add company_name to userRegistrationSchema
  • Update TypeScript types
  1. Database Schema Change (SQL Script)
-- Add company_name column to users tableALTER TABLE users ADD COLUMN company_name VARCHAR(255) NULL;
  1. Backend API Updates
  • Registration endpoint (/api/auth/register): Include company_name in auth metadata
  • Confirmation endpoint (/api/auth/confirm): Extract and store company_name in users table
  • Login endpoint (/api/auth/login): Include company_name in user response
  • Profile endpoints: Support company_name in user updates
  1. Auth Context Changes
  • Update register() function to accept companyName parameter
  • Update user type interfaces to include company_name

Let me create the SQL script first:

Created gipity-sql-scripts/add-company-name-field.sql

Now let me outline all the specific changes needed:

Complete Implementation Plan

Files that need updates:

  1. shared/schema.ts: Add company_name to schemas and types
  2. client/src/pages/Signup.tsx: Remove duplicate field, add company field
  3. client/src/lib/auth-context.tsx: Update register function signature
  4. server/routes.ts: Update registration and confirmation endpoints
  5. server/lib/database.ts: Update any user-related functions if needed

Current Issues to Address:

  • Duplicate confirm password field (lines 276-286)
  • Missing company_name support throughout the stack

Schema Changes Needed:

  • Database: Add company_name VARCHAR(255) NULL to users table (SQL provided)
  • TypeScript: Add company_name to user types
  • Validation: Add company_name to registration schema as optional

API Endpoint Changes:

  • /api/auth/register: Include company_name in metadata
  • /api/auth/confirm: Extract and store company_name
  • /api/auth/login: Return company_name in user object

Frontend Changes:

  • Remove duplicate password field
  • Add company name input field (optional)
  • Update form state and validation
  • Update register function call

This approach maintains the same architecture pattern:

  • Signup → Auth metadata (temporary storage)
  • Email confirm → Users table (permanent storage)
  • Users table = single source of truth

The company_name field will follow the exact same flow as first_name, last_name, user_type, industry_id, and role_id.

Ready to implement these changes once you give the go-ahead!

My second prompt:

Yes I’m happy with that plan. Please go ahead with the changes exactly as you outlined them. Do it carefully so nothing existing breaks

As you can see, by the time I get to give the go ahead, I have a very good idea what it is going to do - it even gave me line numbers so I can go and check if I want.

And sometime I will take it further and say give me the before and after lines of code, together with all filenames that you will change, before we go ahead.

Until such time as we can be 95% confident AI dev agents won’t screw things up, I feel this is a more solid way of taking charge and working alongside agent.

I’d love to hear other people’s thoughts on this workflow.

4 Likes

Thanks @Gipity-Steve ! I just stumbled into a similar approach in the past couple of days. I go through a process of defining the objective, asking for a detailed plan that includes possible risks and conflicts with the existing code and in some cases multiple options to consider.

I push on various points of the Agent’s plan to ensure I understand it and the Agent has fully considered the ramifications. My final request is to ask the Agent to show me the code changes its proposing (without actually executing the changes).

When I hit a stopping point, I ask the Agent to create a .md file with all the details for specification that we’ve just discussed. If I come back to this particular topic in the future, I can ask it to re-familiarize itself by reviewing the spec and we can easily pick up where we left off. (no need to rely on chat history)

1 Like

Brilliant @anilmalhotra2. Yours is the type of workflow approach that is more aligned with how real software people operate. It highlights (for me anyway, others will disagree) the difference between two types of AI developers:

  1. the Sunday fun family project vibe coders
  2. the serious let’s build a real product vibe builders

Appreciate the encouragement @Gipity-Steve ! I think we all run into is this critical issue with vibe coding: when the Agent and the human are vibe coding at the same time bad things happen. One of the two needs to have an enforceable constraint. There was a time when I heard more discussion about the ‘temperature’ of the model. Crank the temp up and the model reacted with more freedom and creativity. Turn the temp down and it was more conservative in its output. It would be great to have that parameter to adjust in Replit.

1 Like

when the Agent and the human are vibe coding at the same time bad things happen

Well, the simple answer is Don’t code yourself, leave it all to agent - which is what vibe coding is meant to be all about! It’s how I now work and I love it.


Btw, I guess Replit’s answer to the temperature thing is their different priced models. The cleverer you want agent to be, the more you pay.

How does having an extended discussion to determine proposed changes, Agent’s suggest changes, revving this, updating etc work within the memory/token limit that a session has? Is there any danger that having a big prompt, a significant research and proposed plan that is then iterated on a few times before coming to a final one to implement, and then going ahead could cause some issues if the Agent runs out of tokens and has to drop some?

1 Like

Been working well for me. In a day of approx 6 hours vibe coding I go through 3 or 4 new chats. As soon as it starts to slur it’s words and act like a drunk, I kill it off, switch to a new one and off it goes with a fresh new context.

I would say though that you should keep your prompts tight. Each one focused on the core task at hand. Do not try to get it to understand the entire code base in every interaction - this is where some people fail I believe. As soon as an agent gets overloaded and bombarded with too much, it will go bananas and the only future for it is in the wood shed.

1 Like

Thank you @Gipity-Steve & @anilmalhotra2 for your insights. I’m a 36year old Sunday vibe coder (who downloaded replit after watching a Diary of a CEO roundtable chat), and after throwing probably $700 of prompts at low/high power agents since May 2025 I’ve got a lawn mowing app which works great in the test environment (except for always forgetting new clients I create), and everything completely breaks when I go to deploy app.

I’ve realised the architecture must be wrong from the start as AI references pages which I deleted at the outset 3 months ago. I got close to deploying it successfully 6 weeks ago, then everything vanished, so I spent 6 weeks putting exact same prompts in rebuilding a pretty similar app to what I originally had (rollback just would not work - it was as if after deploying app I couldn’t roll anything back, and AI couldn’t find the perfectly working code it had once created!).

So now I’m starting to read replit posts/video’s, and this post shows how I should have most likely gone about coding (keeping in mind my knowledge on coding is that there are different languages like Python and Java, and what a different language means I have no idea). I’m a guy that believed I could create an app without knowing a thing about coding and I’m learning a lot from experience.

Possible solutions:

  1. I just took 94 screenshots which show most of the features/parts of the app. Should I try and upload all of these and ask AI to start again making the app look like the screenshots?
  2. Are there certain questions to ask to get AI to delete the messed up code that exists which keeps breaking things? e.g. references to entire segments from day 1 which I got rid of.
  3. Is there a way to not launch the app, and simply use the app in the test environment for say the next 10 months until winter 2026? (I live in Australia). I would take this option any day as I employ people with intellectual disabilities (a bit like me with coding) and send them out with a support worker to service properties in our local community. The person with the disability can’t remember how to service the property each time, and when a different support worker goes with the individual they don’t know the information relating to the property, so this app solves locating information in a timely mannor.

Any help would be much appreciated.

Regards,

Andrew Chadwick

Andrew, I have been in a similar position. I created a completely vibe coded app from a very minimal prompt and had a working prototype in minutes. I got so excited I started adding feature after feature, however each feature often needed a DB change, new logic and started causing problems. The problems multiplied and got harder (and more expensive) to fix. So I stepped back and decided that I will recreate my app from the ground up but with the future in mind so I have spent 2 weeks creating a full product specification that includes many “one day” features so that as the app is built design decisions can be made that will still easily allow for future enhancements without breaking the code. I have also mocked up sample screens, workflows. I have used AI to help me do all of this - not being an app designer. ChatGPT helped me created the wireframe sample pages in their Canvas mode. I would run it through Claude or Gemini and get other points of view. So now I am on the verge of using this spec to create my new app.

Rather than recreate it you could also do a full code audit and fix your existing app. Here is a prompt that @Gipity-Steve shared in another thread that I have tried and was helpful:

## **Replit Compliance Audit + Fix Prompts**

Please review the entire project codebase and perform a **compliance audit** against the architecture and guardrails below. **Only provide the report** at this time — do **not** make any changes until instructed.

Your response must include the following two outputs:

---

### PART 1: Compliance Summary

Output a **simple bullet list**, grouped into two sections:

#### Conforms to Architecture

* \[Bullet points referencing specific files, logic, patterns, or behaviors that match the expected architecture]

#### Violates Architecture

* \[Bullet points describing any violations, misconfigurations, or security concerns]
* Where applicable, reference filenames, function names, and line numbers
* Focus on: architecture violations, security risks, Supabase misuse, environment variable exposure, or direct SQL execution

---

### PART 2: Repair Prompts

Based on the issues found, output a **series of fix prompts** that the user can paste back into Replit to repair the project.

Format like this:

#### Fix Group 1: \[Succinct title, e.g. "Frontend calls Supabase directly"]

* **Prompt to fix**: \[Pasteable Replit prompt]

#### Fix Group 2: \[e.g. "JWT not verified in dashboard route"]

* **Prompt to fix**: \[Pasteable Replit prompt]

...

Please:

* Group related issues into a single fix prompt
* Separate unrelated fixes into their own sections
* Order prompts by priority: **security and architecture first**, cleanup last
* Do not repeat the same fix in multiple groups — consolidate cleanly

---

### Architecture Guardrails

1. The **frontend must never access Supabase directly** — including for auth or session data.
2. All Supabase usage (auth, database, file storage) must occur **only in the backend**, using `@supabase/supabase-js`. The service role key must be used for all database and storage operations. The anon key is permitted only for **sessionless authentication functions** (`signUp`, `signInWithPassword`, `resend()`, password reset, etc.) and must be isolated in a dedicated auth client to prevent RLS contamination.
3. The frontend must communicate **only with the backend** via API routes using `VITE_BACKEND_URL`.
4. Do **not use** `pg`, `drizzle`, `prisma`, or any direct database drivers or ORMs.
5. All file uploads must be routed through the backend and stored in **Supabase storage buckets**.
6. Backend APIs must issue **signed JWTs on login**, and all protected routes must verify the JWT.
7. Supabase keys, SMTP credentials, and other environment secrets must **never be exposed in frontend code or Vite-visible `.env` files**.
8. Project must have a clear and consistent **client/server directory split** (e.g., `/src` for frontend, `/server` for backend).
9. Do **not run Supabase SQL automatically** — all SQL (for tables, policies, triggers) must be **output for manual pasting into Supabase**.
10. **RLS enforcement must be in place** on all Supabase tables, including:
	* Authenticated-user-only access:
	   * `SELECT`, `UPDATE`, and `INSERT` policies using `auth.uid() = id`
	   * Role-based `SELECT` access for admins (`role = 'admin'`)
	* Explicit `service_role` bypass policies for all operations (`SELECT`, `INSERT`, `UPDATE`, `DELETE`)
	* Proper **dual-client architecture**:
	   * `auth client` using the **anon key**, isolated to sessionless auth tasks (`signUp`, `signInWithPassword`, etc.)
	   * `admin client` using the **service role key** for all other DB/storage operations
	   * Ensure no contamination: **do not** reuse the auth client for database queries
11. All backend files must use consistent ES module syntax (`import`/`export`). CommonJS patterns like `require()` or `module.exports` must not be used in any `.ts` or `.js` files. Mixed imports within the same file are not permitted.
12. Advise of any environment variables used in the app that have not yet been defined in the secrets tool
13. Verify no forbidden dependencies are present: check for `drizzle`, `prisma`, `pg` packages in package.json and ensure no related config files exist (drizzle.config.ts, prisma.schema, etc.)
14. The **frontend must never access Supabase file storage directly** - it should use a backend proxy route that uses the admin Supabase client for storage operations to retrieve files and serve them through the backend API, avoiding any direct frontend storage access

Agree with the approach that @Gipity-Steve outlined previously and summarized by @CraigRT. Let me add that I’ve been utilizing the different models for specific purposes within this process. I believe the base model is what generates your initial app from your first prompt. Because there is nothing to break at the beginning, it usually gives you a good start. This is probably the model that has the widest latitude to be creative. However once you pass this step, I’ve found that you need to create more guardrails. Some of those guardrails come from the specification but I believe some of it comes from the model you use.

I keep Extended Thinking on for all work I do after the initial build. When building a specification for a new feature or bug fix, this model has given me the best tradeoff between creative solutions and accurate design. Once an initial specification is built, I will go back multiple times and ask this model to reevaluate the spec to determine if it is the ‘least complex and most elegant way to approach the problem’. I will also ask it to assess the risks of the plan we are discussing. In one recent session, it came back to me three times with simpler solutions until it could finally answer “Yes this is the least complex solution”. This is the behavior I want: a model that will reconsider its own strategy if prompted to do so.

Once I have a good spec and strategy, I turn on the High Power model for implementation. At this phase I don’t want the model to be creative. I want it to execute what we’ve agreed to in the spec and accurately implement the specific code changes itemized. I do ask it to come back to me if there are any unforeseen obstacles.

I just pushed some major fixes that I couldn’t get completed correctly a couple of months ago. I think the combination of a detailed spec and selective use of the models helped get me there.

2 Likes

Thanks @CraigRT & @anilmalhotra2 , your insights and knowledge are invaluable. Learning from humans in the replit community is by far the best way to learn how to get more out of an AI Agent. Thank you. Keep it coming!!

I completely agree with running the Agent in high power mode the whole time. Yes invoices come through quick but I think it’s worth it. I got the lawnmowing app working in real life with my team and they like it. Plenty to iron out but we got it across the line! Without the combination of asking good prompts, using plan mode and high power mode appropriately, the app wouldn’t be functional in real life. The app working in real life puts an end to information flow problems we were having, and let’s my team focus on what they’re good at - caring for people! (And secondly providing a quality lawn mowing experience!)

Looking forwards, I reckon this replit community has a broad range of skills all brought together by a similar common denominator being curiosity to create (this is our culture! And it’s fun!!). Maybe someone could create a competency assessment for replit community members to take to determine which skillsets each person has which can then be matched together to best help each other out? E.g. coding through to launching an app (i have zero idea what jobs/roles this translates to), business analysts, people good at identifying /creating feedback loops, business owners with real world problems of which they don’t realise replit could solve, people with time (to code), people with money (to be used in an innovative incentive structure to get coders to help them), people with grit, people who are creative and think outside the box, people who understand marketing (SEO? I really don’t know much on the marketing front), and I should probably just ask AI for a list of skills required to create great products/services.

There’s got to be the next Jobs, Zuckerberg, Gates, Musk (love them hate them they’re all incredibly intelligent) using this platform as we speak, while simultaneously the next Steven Bartlett, and numerous other entrepreneurs who may not understand replit coding but want to use it.

My hypothesis is that the skills are here to create and sell amazing new products & services, but trust isn’t present due to lack of knowledge. If people can share the right, relevant information about themselves, combined with the right incentive structure, we might be able to put strangers together at low cost with high trust to work together creating and commercialising high quality products/services. Sounds a little magical, but so too was my app when I first thought of it. I had no idea if what I imagined could be created, but in hindsight it turns out the idea was able to be created! It makes me wonder what else can be created. Also is there an easy way to see what everyone else has made? That would probably give great inspiration to others.

Thanks replit community for giving me a space to share my thoughts.

Andrew

1 Like

The costs in “plan mode” are ridiculous IMHO. You could download your repo as a zip and ask Chatgpt for a plan instead.

Try this type of prompt in Agent 3 plan mode

Lets focus on “place detailed problem analysis here“. You are the senior engineer, so debug/investigate anything that is necessary to provide a complete plan for implementation. Do not delegate debugging/investigation to the assistant and provide a concrete user prompt to implement your plan. In your response provide a RAW escaped markdown prompt to implement your plan with concrete code change examples for the Claude assistant.

Agent 3 Plan cost for an RBAC issue I am working on:

And then copy and paste the prompt into the assistant and ask the assistant to implement the plan verbatim.

This is called meta prompting:

Meta prompting is a prompt engineering technique where a Large Language Model (LLM) is used to generate, refine, or optimize other prompts. Instead of a human writing a prompt directly, the user provides a high-level request, and the LLM acts as a “prompt engineer” to create a detailed, effective prompt tailored for a specific task or context. This process can automate prompt creation and improve the quality and efficiency of the final output from an AI system.


ANOTHER FUN TIP:

I asked Agent 3 to do the following:

Break its plan down into small executable task that the assistant can execute. Be verbose and treat this documentation as if a junior level engineer will be responsible for implementing it, and include complete and exact code change blocks and output the project plan into an .md file.

Then provide me an escaped RAW markdown prompt for the assistant to go read that .md file and execute the project plan.


KEY TAKEAWAY:

Learning more efficient ways to interact with the assistant is critical to controlling prompt costs. Certain tasks are better suited for Agent 3 and should not be delegated to the assistant—but you may be surprised at what the assistant can accomplish with the right prompt and context.


PRO TIP:

Replit uses RAG/repo indexing to “ground” the agent in context. One of the biggest draw backs with RAG is that the vector database can become “Stale”.

  • Ultimately this means the agent is completing its analysis against out of date code.

Don’t forget to challenge Agent 3 on this if you are using this pattern, as the Agent will be referencing stale code indexes in RAG.