返回列表

博客

教程:使用 Tactic Remote 远程构建全栈应用

跟随我们使用 iPhone 指挥 Claude Code 构建一个完整的任务管理应用——证明从移动端完成大量开发工作是完全可行的。

发布于 标签: 上手教程 / fullstack / workflow / hands-on
博客

继续查看该栏目下的产品与工程更新。

浏览此分类

本教程将带你完整地构建一个全栈应用——一个带有 React 前端的任务管理 API——全程通过 Tactic Remote 完成。你将从 iPhone 上指挥 Claude Code,而你的 Mac 负责执行繁重的工作。

完成后,你将拥有一个可运行的应用,并获得 Tactic Remote 所实现的远程开发工作流的实践经验。

前置条件

开始之前,请确保你已具备:

  • Tactic Remote 已设置并连接(入门指南)
  • Mac 上已安装 Node.js 18+
  • 一个可用的项目目录(我们将使用 ~/projects/taskflow)

第一部分:项目搭建(10 分钟)

在 iPhone 上打开 Tactic Remote,启动一个指向项目目录的新会话。

提示词 1:搭建项目脚手架

向 Claude Code 发送以下提示词:

Create a full-stack task management application called TaskFlow.

Backend:
- Express.js server with TypeScript
- SQLite database with better-sqlite3
- RESTful API: CRUD for tasks and projects
- Input validation with zod

Frontend:
- React 18 with TypeScript
- Vite for bundling
- Tailwind CSS for styling
- React Query for data fetching

Set up the monorepo structure with packages/api and packages/web.
Use a root package.json with workspaces.

Claude Code 将在此任务上工作 3-5 分钟。你会看到它创建目录、编写配置文件和安装依赖。这时候可以放下手机——Tactic Remote 会在任务完成或需要审批时通知你。

注意事项: Claude Code 很可能会请求批准运行 npm install。从通知中批准即可——它是在为你的项目安装依赖。

提示词 2:验证搭建结果

脚手架完成后,验证一切是否正常工作:

Start both the API server and the frontend dev server.
Run any initial tests. Report the URLs where each is accessible.

你应该会看到 Claude Code 启动服务器并回报 URL,例如 API 在 http://localhost:3001,前端在 http://localhost:5173。

第二部分:构建 API(20 分钟)

现在让我们构建包含实质业务逻辑的后端 API。

提示词 3:数据库表结构和模型

Create the database schema and models:

Tables:
- projects: id, name, description, color (hex), created_at, updated_at
- tasks: id, project_id (FK), title, description, status (todo/in_progress/done),
  priority (low/medium/high/urgent), due_date, created_at, updated_at

Include:
- Migration system that runs on server start
- Type-safe model layer with full TypeScript types
- Seed data: 2 sample projects with 5 tasks each

这个提示词展示了 AI 辅助开发的一个关键优势:你描述做什么,Claude 处理怎么做。结果将包含正确类型化的模型、SQL 迁移和种子数据——这些工作人工开发者需要 30-60 分钟才能完成。

提示词 4:带验证的 API 路由

Implement the full REST API:

Projects:
- GET /api/projects (list all, with task counts)
- POST /api/projects (create, validate with zod)
- PUT /api/projects/:id (update)
- DELETE /api/projects/:id (cascade delete tasks)

Tasks:
- GET /api/projects/:id/tasks (list by project, support ?status= filter)
- POST /api/projects/:id/tasks (create with validation)
- PUT /api/tasks/:id (update, including status transitions)
- DELETE /api/tasks/:id

Include proper error handling with consistent error response format.
Add request logging middleware.

审批提示: Claude Code 可能会请求批准修改多个文件。查看审批卡片中的文件列表——它应该仅限于项目 packages/api/ 目录内的文件。如果你看到超出此范围的文件,请拒绝并澄清提示词。

提示词 5:测试 API

Write integration tests for all API endpoints using vitest and supertest.
Test both success cases and error cases (invalid input, not found, etc.).
Run the tests and report results.

在终端视图中观察测试结果流过屏幕。即使在手机屏幕上,绿色的通过测试也令人满足。如果有测试失败,Claude Code 通常会自动诊断并修复问题。

第三部分:构建前端(25 分钟)

提示词 6:核心 UI 组件

Build the frontend UI:

1. Layout with sidebar (project list) and main area (task board)
2. ProjectList component: shows projects with task counts and color indicators
3. TaskBoard component: kanban-style columns for todo/in_progress/done
4. TaskCard component: shows title, priority badge, due date
5. Drag-and-drop between columns to change task status

Use React Query for all data fetching. Show loading skeletons.
Style with Tailwind - clean, modern look with the project color as accent.

这是目前为止最大的提示词。Claude Code 将生成多个组件、设置路由、配置 React Query 并实现拖放功能。预计需要 5-8 分钟。

提示词 7:表单和交互

Add interactive features:

1. Create Project modal: name, description, color picker
2. Create Task modal: title, description, priority selector, due date picker
3. Inline task editing: click to edit title, click priority to cycle through levels
4. Delete confirmation dialogs for projects and tasks
5. Toast notifications for successful operations

All forms should validate input and show helpful error messages.

提示词 8:打磨和响应式设计

Polish the UI:

1. Make everything fully responsive (mobile-friendly at 375px+)
2. Add empty states for projects and tasks (with calls-to-action)
3. Add a search/filter bar: filter tasks by title or status
4. Add keyboard shortcuts: N for new task, / for search
5. Add subtle animations for card transitions and modal open/close

Fix any visual issues you notice.

第四部分:集成与最终验证(10 分钟)

提示词 9:端到端验证

Verify the complete application:

1. Start the API server and frontend
2. Create a new project through the UI
3. Add several tasks with different priorities
4. Move tasks between columns
5. Edit and delete tasks
6. Test responsive layout at mobile sizes
7. Report any issues found and fix them

Provide the final URLs to access the application.

提示词 10:文档

Create a README.md in the project root with:

1. Project description and screenshot placeholder
2. Tech stack overview
3. Getting started instructions (install, run, test)
4. API endpoint documentation with example requests/responses
5. Project structure explanation

你刚刚构建了什么

在大约一小时的时间里,你从手机上指挥 Claude Code 创建了:

  • 一个带有 SQLite 持久化的 TypeScript Express API
  • 一个带有拖放看板的 React 前端
  • 完整的 CRUD 操作和验证
  • 集成测试
  • 响应式设计
  • 项目文档

这是一个非平凡的应用——数十个文件中包含数百行代码。而你构建它的时候根本不在办公桌前。

远程全栈开发技巧

将工作分解为清晰的阶段。 不要试图在一个提示词中描述整个应用。分阶段的提示能产生更好的结果,因为每个提示都建立在前一阶段已验证的工作之上。

每个阶段后都要验证。 每完成一个主要工作后,让 Claude Code 运行测试或启动服务器。尽早发现问题可以防止级联错误。

善用审批通知。 审批流程不仅仅是安全功能——它是一个检查点,你可以在此审查 Claude Code 正在做什么,并在需要时纠正方向。

不要持续盯着屏幕。 远程开发的核心就是自由。发送提示词,放下手机,收到通知时再回来。信任这个系统。

下一步

立即体验 Tactic Remote

用手机远程控制编程 Agent

连接 Mac、Windows 或 Linux 电脑上的 Claude Code、Codex 等 Agent,在 iPhone 或 iPad 上查看进展并发送下一条要求。