An advanced walkthrough of how to strategically use ChatGPT, GitHub Copilot, and Cursor for supercharging frontend development.
Youβll learn:
- Differences between AI agents and chatbots
- Advanced prompt engineering for each tool
- Workflow design for AI-augmented coding
- Full code examples (React + Tailwind)
- Live coding walkthroughs for each tool
- Tool-specific input vs output comparisons
- Tips & tables on when and how to use each tool
- Real-world AI tooling case studies
| Feature | AI Chatbot (e.g., ChatGPT) | AI Agent (e.g., Cursor, Copilot) |
|---|---|---|
| Primary Mode | Conversational, text-based | Directly edits or autocompletes in your IDE |
| Context Awareness | Maintains global context in chat | Operates on current file/project context |
| Autonomy | Responds to you | Acts on your codebase proactively/reactively |
| Use Case Fit | Planning, generating, refactoring | Scaffolding, refactoring, editing live code |
| Examples | ChatGPT, Claude | Cursor, GitHub Copilot, Replit Ghostwriter |
Goal: Full solutions, architecture, reasoning, refactoring
Prompt Tips:
- Be verbose and clear
- List constraints and technologies
- Ask for best practices or trade-offs
- Use "you are a senior dev..." tone for quality output
Example Prompt:
You're a senior frontend engineer. Write a complete React component using Tailwind CSS that implements a responsive navbar:
- Hamburger icon on mobile
- useState toggle logic
- Semantic HTML and accessibility
- Mobile-first design with ARIA attributes
Explain accessibility and optimization considerations.Goal: Fast file-specific mutations
Prompt Tips:
- Be surgical: "Edit this to..."
- Avoid general tasks like "build X" β Cursor shines in modifying, not generating from scratch
- Use commands like "extract", "make responsive", "animate"
Example Prompt:
Edit this component to:
- Add a mobile hamburger toggle using useState
- Hide/show nav links based on toggle
- Keep the logo and layout unchanged
- Animate menu open/closeGoal: Fast autocomplete based on your typing
Prompt Tips:
- Start typing the code you want to see
- Copilot learns from your patterns and file structure
- Works great for loops, component scaffolds, props, Tailwind classes
Example Trigger:
const Navbar = () => {
return (
<nav className="bg-gray-800 p-4 flex justify-between items-center">
<div className="font-bold text-xl">Logo</div>Copilot will suggest the rest inline as you type.
βCreate a responsive navbar in React using Tailwind CSS. It should show a hamburger menu on small screens and full nav links on desktop. Add toggle logic for the menu.β
import { useState } from 'react';
const Navbar = () => {
const [open, setOpen] = useState(false);
return (
<nav className="flex items-center justify-between flex-wrap bg-gray-800 p-4 text-white">
<div className="text-xl font-bold">Logo</div>
<button
className="lg:hidden block"
onClick={() => setOpen(!open)}
aria-label="Toggle navigation"
>
β°
</button>
<ul className={`${open ? 'block' : 'hidden'} lg:flex space-x-4`}>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
);
};
export default Navbar;import { useState } from 'react';
const Navbar = () => {
const [isOpen, setIsOpen] = useState(false);
return (
<nav className="bg-gray-900 text-white p-4 flex items-center justify-between">
<div className="text-lg font-bold">Logo</div>
<div className="lg:hidden" onClick={() => setIsOpen(!isOpen)}>β°</div>
<div className={`${isOpen ? 'block' : 'hidden'} w-full lg:flex lg:items-center lg:w-auto`}>
<ul className="flex flex-col lg:flex-row gap-4 mt-2 lg:mt-0">
<li><a href="#">Home</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</nav>
);
};
export default Navbar;<nav className="flex items-center justify-between p-4">
<div className="text-xl font-bold">Logo</div>
<button className="lg:hidden">β°</button>
<ul className="hidden lg:flex space-x-4">
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>| Feature | Copilot | Cursor | ChatGPT |
|---|---|---|---|
| Toggle Logic | β None | β
useState + toggle logic |
β
useState + ARIA |
| Full Component | β Partial JSX | β Complete w/ logic | β Complete + explanations |
| Contextual Editing | β | β File-aware edits | β (text only) |
| Accessibility | β | β Always | |
| Ideal Usage | Fast typing | Refactor/modify existing code | Design & generate full features |
Write a complete responsive navbar in React using Tailwind. Add toggle logic with useState. Include accessible markup and explain your design decisions.Make this navbar responsive with Tailwind. Add a hamburger menu with toggle state. Animate the open/close.const Navbar = () => {
const [open, setOpen] = useState(false);
return (
<nav className="bg-white p-4 flex justify-between items-center">Copilot continues from here automatically.
Prompt:
Write a full responsive React + Tailwind navbar with hamburger toggle, useState, semantic HTML, accessibility, transitions. Explain each part.π¦ Output:
- Full JSX
- Tailwind classes
- Toggle logic
- Accessibility built-in
Initial Code:
const Navbar = () => {
return (
<nav>
<div>Logo</div>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
);
};Cursor Prompt:
Edit this to make the nav responsive with Tailwind, add a hamburger menu with state toggle.π§ Output:
- Tailwind layout
- Toggle logic
- Inline update β no copy-paste needed
Type:
const Navbar = () => {
const [open, setOpen] = useState(false);
return (
<nav className="bg-white p-4 flex justify-between items-center">
<div className="font-bold text-xl">Logo</div>Copilot will:
- Auto-fill toggle button
- Auto-fill nav links
- Predict layout classes
| Phase | Tool | Why |
|---|---|---|
| π¨ Design Architecture | ChatGPT | Best for complete features with constraints |
| π οΈ Code Mutation | Cursor | Knows your code context, edits smartly |
| β‘ Scaffolding UI | Copilot | Super-fast at inline JSX and Tailwind prediction |
- Use ChatGPT for entire components and architectural thinking
- Use Cursor for fast refactor, live mutation, and cleanup
- Use Copilot to fill in repetitive logic, markup, and classnames
- Mix & match! Combine tools for optimal flow
- Advanced prompt engineering is key β learn to speak AI fluently
Cursor is deeply integrated with Git. Here's how you can use it to improve your Git workflows:
-
Cursor can summarize staged changes:
Prompt: "Summarize these changes and write a commit message."β Ideal for reviewing large PRs or understanding teammate commits.
-
Cursor can auto-generate high-quality, conventional commits:
Prompt: "Generate a semantic commit message for these changes." Output: "feat(navbar): add responsive toggle menu using Tailwind and useState"
-
Ask Cursor:
Prompt: "Refactor the code to follow the Single Responsibility Principle. Only change this file." -
After refactor, auto-generate:
Prompt: "Summarize the diff and generate a commit."
Using ChatGPT or Copilot to write tests:
Prompt for ChatGPT:
Write unit tests in React Testing Library for a navbar component that:
- Toggles menu with a button
- Has different layouts for mobile and desktop
- Uses useStateOutput:
import { render, fireEvent, screen } from '@testing-library/react';
import Navbar from './Navbar';
test('shows menu on mobile toggle', () => {
render(<Navbar />);
const button = screen.getByLabelText(/toggle navigation/i);
fireEvent.click(button);
expect(screen.getByText(/home/i)).toBeVisible();
});Using tools like Husky + Cursor CLI or OpenAI API:
#!/bin/sh
diff=$(git diff --cached)
msg=$(echo "$diff" | curl -X POST https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Write a semantic commit message for this diff:\n'"$diff"'"}]
}' | jq -r '.choices[0].message.content')
echo "$msg" > $1Task:
- Refactor a large
FormWizardcomponent - Document every step
Prompt:
Refactor this React component into smaller parts:
- StepController
- StepProgressBar
- WizardForm
Each with props defined. Add JSDoc comments.ChatGPT Output:
- 3 components
- JSDoc
- Better separation of concerns
Commit Generated:
refactor(form): split FormWizard into subcomponents with clear props and docs
Before:
<Button onClick={toggle}>Open</Button>
{show && <Sidebar />}Prompt:
Refactor to use useReducer instead of useState for toggle.Cursor Output:
- Added reducer
- Cleaner toggle logic
Prompt (afterwards):
Summarize the diff and write a commit message.Commit:
refactor(ui): replace useState with useReducer for sidebar toggle
Flow:
- Copilot used to scaffold a Next.js API route
- ChatGPT used to write the commit summary
Prompt:
Write a commit message for this endpoint creation:
- /api/send-email
- Uses nodemailer
- Validates inputCommit:
feat(api): add /send-email endpoint with input validation and nodemailer integration
- ChatGPT: Best for semantic commit messages and code documentation
- Cursor: Git-aware, ideal for local diffs, commit summaries, and edits
- Copilot: Fast scaffolding β use with Git hooks + external summarization
Use GPT to translate product requirements or UI wireframes into reusable component trees using Atomic Design principles.
Given this user story: "Users can upload and crop a profile picture on mobile and desktop", generate a component hierarchy using Atomic Design. Include props and responsibilities.Atoms: Button, Input, ImagePreview
Molecules: ImageUploadInput (Input + Preview), CropperToolbar
Organisms: ProfileImageUploader
Props:
- onUpload: (file: File) => void
- aspectRatio: number
- onCrop: (cropData: object) => void
Feed GPT screenshots from Figma (via vision tools) or describe your design manually.
Automate your component documentation and showcase states quickly with GPT.
Write a Storybook story for a ToggleSwitch component with the following props:
- checked (boolean)
- onChange (function)
- disabled (boolean)import React from 'react';
import { ToggleSwitch } from './ToggleSwitch';
export default {
title: 'Components/ToggleSwitch',
component: ToggleSwitch,
};
export const Default = () => <ToggleSwitch checked={false} onChange={() => {}} />;
export const Checked = () => <ToggleSwitch checked={true} onChange={() => {}} />;
export const Disabled = () => <ToggleSwitch disabled={true} checked={false} onChange={() => {}} />;Legacy code example:
class Modal extends React.Component {
state = { open: false };
toggle = () => this.setState({ open: !this.state.open });
render() {
return this.state.open ? <div>{this.props.children}</div> : null;
}
}Convert this class-based Modal to a functional component using hooks. Add JSDoc and split toggle logic into a separate hook.import { useState } from 'react';
/** useModal manages open/close state for modal dialogs */
export const useModal = () => {
const [open, setOpen] = useState(false);
const toggle = () => setOpen(prev => !prev);
return { open, toggle };
};
export const Modal = ({ children }) => {
const { open } = useModal();
return open ? <div>{children}</div> : null;
};Write Playwright tests for a login + checkout flow in an e-commerce app.test('user can login and checkout', async ({ page }) => {
await page.goto('/login');
await page.fill('#email', 'test@ai.com');
await page.fill('#password', '123456');
await page.click('button[type=submit]');
await page.goto('/shop');
await page.click('text=Add to Cart');
await page.goto('/cart');
await page.click('text=Checkout');
await expect(page).toHaveURL('/confirmation');
});Check this HTML snippet for accessibility issues and suggest fixes:
<button>π</button>Issue: Button has no accessible name.
Fix: Add aria-label or text.
<button aria-label="Search">π</button>
You can chain prompts:
Now generate a table summarizing all WCAG 2.1 violations found.Here are two examples of commits:
- feat(button): add loading state to async buttons
- fix(navbar): hide overflow menu in Safari
Now generate a message for:
Diff: Added error message display to LoginForm on 401 responseLet's reason step by step:
1. Define the component name and purpose.
2. Declare the prop types.
3. Implement the component.
4. Write a test file.This helps guide the model through a structured, high-quality output.
Create an internal prompt library your team can pull from. Categories:
- Code Style: "Convert this to a reducer pattern using switch-case."
- Test Writing: "Write unit tests for this using Jest and RTL."
- Docs: "Add JSDoc to all functions and interfaces."
Use Notion/Markdown synced with VS Code snippets for real-time usage.
Use LangChain or Shell scripting + GPT APIs to create full CI-like chains.
# 1. Generate component
generate_component.sh "LoginForm with email/password, form validation"
# 2. Generate test
generate_test.sh LoginForm
# 3. Ask GPT to format + commit
gpt_commit.shSummarize changes, write a commit message, and list test coverage gaps.Extract a design token JSON from this Tailwind config:
- Colors: gray, blue
- Font size: sm, base, lg
- Spacing: 2, 4, 8{
"color": {
"gray": "#6b7280",
"blue": "#3b82f6"
},
"fontSize": {
"sm": "0.875rem",
"base": "1rem",
"lg": "1.125rem"
},
"spacing": {
"2": "0.5rem",
"4": "1rem",
"8": "2rem"
}
}Can be fed into:
- Style Dictionary
- Figma Tokens plugin