Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Vibe Coding Hands-on Project

Vibe Coding Hands-on Project

In this chapter we'll fully demonstrate the entire Vibe Coding process - not burying ourselves in writing code, but describing requirements in natural language and letting AI execute.

The ultimate goal is to build a real, usable Web application without writing a single line of code.


First understand: what exactly is Vibe Coding

The name Vibe Coding comes from a tweet by OpenAI co-founder Andrej Karpathy.

What he meant was:You immerse yourself in the product's "vibe", forget the code details, only describe what you want, and AI makes it happen.

How is it different from the way you program now

Traditional programming Vibe Coding
Memorize syntax and APIs, look up docs Describe intent in natural language, AI generates code
Write line by line by hand, debug it yourself Iterate through multi-turn conversations, AI writes + AI revises
Design the whole thing first, then write it line by line Build while chatting, adjust while building
When hitting a bug, search and figure it out yourself Toss the error message straight to AI and let it fix it
Your role is the implementer Your role is the designer

The core working rhythm of Vibe Coding

The whole development process follows a simple three-step loop:

Step What you do What AI does
1. Plan Describe requirements and goals Analyze requirements, give a technical plan
2. Execute Confirm the plan, give constraints Generate code, modify files
3. Verify Run verification, check results Fix errors, adjust output

Verify each step as soon as it's done, and only enter the next loop after it passes.

This is the core secret of Vibe Coding -not throwing all requirements at AI at once, but advancing one small step at a time, confirming the direction is right at each step.


Environment Preparation

You only need three things, and all of them are free.

1. VS Code editor

Download address:https://code.visualstudio.com

VS Code tutorial:

https://www.runoob.com/vscode/vscode-tutorial.html

VS Code supports Windows / macOS / Linux and is completely free.

2. GitHub Copilot (built into VS Code, no installation needed)

The latest version of VS Code already has GitHub Copilot built in,no need to install any extensions.

We only need to do one thing:

  1. Open VS Code and click the account icon
  2. Select Sign in with GitHub and log in with your GitHub account
  3. After login, Copilot activates automatically

If you don't have a GitHub account, first go github.com register one for free.

Open the editor and you will see the Copilot entry; just log in with your GitHub account, no need to install plugins from the Extensions marketplace.

After logging in, check:

Click the small icon in the top-right to bring up the Copilot chat window:

3. Node.js

Download address:https://nodejs.org

Node.js tutorial:https://www.runoob.com/nodejs/nodejs-tutorial.html

Choose the LTS version, then after installing open the terminal to verify:



node -v   # 应显示 v20.x.x 或更高

npm -v    # 应显示 10.x.x 或更高

Get to know a few shortcuts

These two shortcuts are the ones you'll use most:

Keyboard shortcut Function When to Use
Ctrl+I (Mac: Cmd+I) Inline Chat Select a piece of code and have AI explain or modify it
Ctrl+Shift+I (Mac: Cmd+Shift+I) Chat panel Long conversations related to new feature development
Tab Accept completion AI gives a gray suggestion; press Tab to accept
Esc Reject completion If AI's suggestion is wrong, press Esc to ignore it

Project kickoff: what are we building

Now we'll use the Vibe Coding approach to build a completetask management app.

Feature list

Tech stack choices

What it does What we use Why we chose it
Front-end framework Vue 3 Easy to learn, active community, plenty of Chinese-language resources
Build Tools Vite Fast startup, officially recommended by Vue
Style Tailwind CSS No need to write CSS files; write style classes directly in HTML
Data storage localStorage Built into the browser, no backend server needed
Project name vibe-coding-runoob Our hands-on project name

Round one conversation: build the skeleton

Now we begin real Vibe Coding,not telling AI all requirements at once, but going step by step.

Step 1: Create the project

Open the terminal and create the project:

npm create vite@latest vibe-coding-runoob -- --template vue

Open a new terminal, enter the project, then install tailwindcss and use the code . command to open the project in VS Code:



cd vibe-coding-runoob

npm install

npm install -D tailwindcss @tailwindcss/vite

code .

Now VS Code has the project open; press Ctrl+Shift+I(Mac: Cmd+Shift+I) to open the Copilot Chat panel; there is also a panel-toggle button in the top-right:

Step 2: First conversation

Type the following into the Chat panel, i.e. say what you want in natural language:



我在开发一个任务管理 Web App,项目名 vibe-coding-runoob。

技术栈:Vue 3 + Vite + Tailwind CSS。



Please help me set up the project skeleton, create the following files:



1. src/types/task.ts — 定义 Task 类型

   字段:id, title, description, status, priority, dueDate, createdAt

   status 可选值:'todo' | 'in-progress' | 'done'

   priority 可选值:'low' | 'medium' | 'high'



2. src/App.vue — 应用主页面

   - 顶部导航栏(标题"Vibe Coding Runoob")

   - 中间显示任务列表区域



要求:

- 使用 Vue 3 script setup 语法

- 使用 Tailwind CSS 做样式

- 界面简洁干净,主色调用 indigo(靛蓝色)

- 现在先用假数据展示,后面再接真实功能

AI will output code section by section and modify the file code; you click Keep to let it write into the file automatically.

It will ask to run a command; you just need to click Allow:

Step 3: Verify

After AI finishes writing the code, it will prompt us to run in the terminal:



npm run dev

Click the open-terminal button in the top-right, then run the command in the terminal:

Open http://localhost:5173 in the browser; if you see the page, the first step succeeded.

The finished result is as follows:

This is the first round of Plan -> Execute -> Verify. You described the goal, AI executed it, and you verified the result. Every following round follows this rhythm.

Ran into code you don't understand?

Vibe Coding doesn't require you to understand every line. But if some code is completely opaque to you, select it and press Ctrl+I, and type:



用通俗的中文解释这段代码在做什么

AI will explain it in language you can understand.


Round two conversation: implement the task list and form

The skeleton is running; now let's implement the real features.

Step 1: Task card component

Continue typing in the Chat panel:



Create the src/components/TaskCard.vue component:



功能:

- 展示单个任务的信息:标题、描述、优先级标签、截止日期

- 优先级用颜色区分:high 红色、medium 黄色、low 绿色(左边框即可)

- 点击左侧复选框标记任务为完成(标题加删除线)

- 右上角有删除按钮(× 图标)

- 鼠标悬停时卡片微微放大(hover:scale-[1.02])



Props 接收:task(Task 类型)

Emit 事件:toggle(切换完成状态)、delete(删除任务)

After AI generates, click Keep for file writes and Allow for command execution; the final result:

Then create the task list container:



Create the src/components/TaskList.vue component:



功能:

- 接收任务列表,用 TaskCard 展示每一项

- 任务按创建时间倒序排列(最新的在上面)

- 顶部有状态筛选按钮:全部 / 待办 / 进行中 / 完成

- 没有任务时显示空状态提示:"还没有任务,点击下方按钮创建第一个吧"

Step 2: Create the task form



Create src/components/TaskModal.vue component:



功能:

- 点击"+ 新建任务"按钮打开弹窗

- 表单字段:标题(必填)、描述(选填)、优先级(下拉选择)

- 标题为空时显示红色错误提示"标题不能为空"

- 点击弹窗外的灰色遮罩关闭弹窗

- 按 ESC 键关闭弹窗

- 提交后用 emit 把新任务传给父组件



使用 v-model 绑定表单数据

使用 Teleport 把弹窗渲染到 body 下

Step 3: Assemble the components

Now update App.vue to combine TaskList and TaskModal together:



更新 src/App.vue:



- 引入 TaskList 和 TaskModal 组件

- 使用 reactive 管理 tasks 数组(先用示例数据)

- 实现 addTask 函数:接收 TaskModal 提交的数据,添加到 tasks 数组

- 实现 toggleTask 和 deleteTask 函数

- TaskModal 的显示/隐藏用 ref(false) 控制



示例数据包含 2 条任务,让页面看起来不空

Step 4: Verify

Manually walk through it in the browser: create a task -> click the checkbox to mark it done -> delete the task. Once all features work, move to the next round.


Round three conversation: data persistence

Right now tasks disappear on refresh. We need to store the data in the browser's localStorage.

Tell AI your requirement



现在任务数据只存在内存里,刷新就没了。请把数据持久化到 localStorage:



1. 创建 src/utils/storage.ts:

   - saveTasks(tasks): 把任务数组存为 JSON

   - loadTasks(): 读取并解析 JSON,读取出错时返回空数组

   - 存储键名:vibe-coding-runoob-tasks



2. 更新 src/stores/taskStore.ts:

   - 用 Vue reactive 管理状态

   - 初始化时从 localStorage 加载数据

   - 使用 watch 自动监听变化并保存(deep: true)

   - 导出 addTask、updateTask、deleteTask 函数

   - 首次使用时如果没有数据,自动创建 3 条示例任务



3. 更新 App.vue,改为从 taskStore 获取数据和方法

Validation



# In the browser:

1. 添加几条任务

2. 刷新页面 → 任务还在!

3. 按 F12 打开开发者工具 → Application → Local Storage

4. 找到 vibe-coding-runoob-tasks,查看存储的 JSON 数据

If the data is gone, paste the error message from the F12 console to AI and let it fix it.


Round four conversation: Kanban view

Requirement description



我想添加一个看板视图(Kanban),文件:src/components/KanbanBoard.vue



功能:

- 三列:待办 | 进行中 | 已完成

- 任务卡片显示在对应状态的列中

- 卡片可以拖拽到其他列(用 HTML5 原生拖拽 API)

- 拖入新列时自动更新任务的 status

- 在 App.vue 顶部加两个 Tab 按钮:"列表"和"看板"

- 切换时保持数据一致



注意:不需要引入任何拖拽库,用原生的 dragstart、dragover、drop 事件即可。

Verify after AI generates: drag a card from "to-do" to "in progress" and confirm the task status updated.


Round five conversation: dark mode and mobile adaptation

Dark mode



添加深色模式:创建 src/components/ThemeToggle.vue



功能:

- 点击按钮切换亮色/深色模式

- 在 html 标签上添加/移除 dark class

- 用 localStorage 记住用户选择(键名:vibe-coding-runoob-theme)

- 首次访问时跟随系统设置(prefers-color-scheme)

- 按钮放在导航栏右侧



同时给所有组件添加 dark: 前缀的深色样式。

Mobile adaptation



适配手机屏幕(375px 宽):



- 看板三列在手机上改成竖向单列布局

- 任务模态框在手机上改成从底部滑出的样式

- 所有按钮的点击区域不小于 44px

- 表单输入框字号不小于 16px(防止 iOS 自动缩放)

- 导航栏在手机上用汉堡菜单



使用 Tailwind 的响应式类:sm: md: lg:

Verify: press F12 in the browser, switch to phone mode (375px), and check each page one by one.


What to do when you hit a Bug: the universal troubleshooting template

This is the Vibe Coding "first-aid kit" - whenever you hit any error, just use this template:



I encountered a problem, please help me fix it:



【错误信息】

把终端或浏览器控制台的完整错误粘贴在这里



【我想实现的效果】

描述你期望发生什么



【我已经尝试过的方法】

列出你试过但没解决的操作

AI will automatically locate the problem and give a fix based on the error message. You don't need to analyze the cause yourself.


Let AI review your code

After finishing each major feature, type in Chat:



Please review the code of my current project, focusing on:

1. 有没有安全风险

2. 有没有性能问题

3. 错误处理是否完整

4. 有没有可以简化的地方

AI will list problems and fix suggestions point by point. This is something only experienced developers could do - but with AI, you can do it too.


Deploy and go live

The project is done; the last step is to put it online so anyone can access it.

Push to GitHub



$ git init

$ git add .

$ git commit -m "feat: vibe-coding-runoob 任务管理应用"

# After creating a repository with the same name on github.com:

$ git remote add origin https://github.com/你的用户名/vibe-coding-runoob.git

$ git push -u origin main

Deploy to Vercel

  1. Access the vercel.com, log in with your GitHub account
  2. Click Add New Project and select the vibe-coding-runoob repository
  3. Choose Vite as the Framework, then just click Deploy
  4. Wait 1-2 minutes and you'll get a xxxx.vercel.app domain

Send the link to friends and they can use your app.


Vibe Coding summary

The formula for writing a good prompt

A good prompt = Goal + constraints + context

Not recommended Recommend
Make me a task list Create a TaskList.vue component. Features: display a task list with title, status, and priority tags. Use Tailwind CSS, pass data in via props. Do not introduce third-party UI libraries.

Iteration rhythm



每次对话 → 只做一个功能

每次修改 → 立刻在浏览器里验证

每个功能完成 → 立刻 git commit

每天结束 → push 到 GitHub

Don't pile up many changes and test them all at once; that's just making trouble for yourself.

Don't leave these things to AI