skills/disabled/frontend-backend-integration/SKILL.md
前后端对接。当用户需要检查前后端API对接、调试接口调用、确保数据格式一致时使用此技能。
npx skillsauth add aaaaqwq/agi-super-skills frontend-backend-integrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
此技能专门用于前后端API对接检查和调试,包括:
首先了解项目的前后端目录结构:
# 查看前端目录
ls frontend/src/
ls frontend/src/api/
ls frontend/src/stores/
# 查看后端目录
ls backend/
ls backend/app/
# 查找API文档
find docs/ -name "*api*" -o -name "*API*" -o -name "*接口*"
find backend/docs/ -type f
find frontend/docs/ -type f
docs/api-reference.md - API参考文档docs/frontend/ - 前端相关文档backend/tests/test_*.py - 后端测试文件(包含API行为)backend/README.md - 后端说明# backend/app/main.py 或类似文件
# 重点查找:
# - @app.get/post/put/delete 装饰器定义的路由
# - response_model 指定的响应格式
# - 参数定义(query, path, body)
# backend/app/schemas.py
# 重点查找:
# - Pydantic模型定义
# - 字段类型和验证规则
# - ApiResponse格式
# - PaginatedResponse格式
# backend/tests/test_main.py
# 重点查找:
# - 测试请求的参数格式
# - 预期的响应格式
# - 断言检查的数据结构
// frontend/src/api/index.js
// 重点查找:
// - baseURL配置
// - axios拦截器处理
// - 各个API方法的参数和返回值
// frontend/src/stores/*.js
// 重点查找:
// - API调用方式
// - 响应数据处理方式
// - 数据提取路径(res.data vs res.items)
// frontend/src/views/*.vue
// 重点查找:
// - API调用时机
// - 数据使用方式
// - 错误处理
| 后端返回格式 | 前端应提取 | 验证点 |
|--------------|------------|--------|
| ApiResponse {code, message, data} | res.data | 前端是否用.data |
| PaginatedResponse {items, total, page} | res.items, res.total | 前端是否直接访问 |
| 嵌套对象 {category: {id, name}} | item.category.name | 组件是否正确访问 |
| 数组字段 {tags: [...]} | item.tags.map() | 是否作为数组处理 |
后端配置:
# backend/app/config.py
# 查找 host, port 配置
# 默认通常是 0.0.0.0:8000
前端代理配置:
// frontend/vite.config.js
// server.proxy['/api'] 应指向后端地址
// 例如:target: 'http://localhost:8000'
前端baseURL:
// frontend/src/api/index.js
// baseURL 应为 '/api'(走代理)
症状:前端获取不到数据,显示undefined
原因:后端有些API返回ApiResponse包装,有些直接返回数据
解决方案:
// 检查后端返回格式,调整前端处理
// 如果是 ApiResponse 格式:
this.data = res.data
// 如果是直接返回格式:
this.data = res
症状:浏览器控制台显示CORS policy错误
解决方案:
# backend/app/main.py
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173"], # 前端地址
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
症状:前端启动后无法访问后端API
解决方案:
netstat -ano | findstr :8000检查端口占用症状:某些数据显示不正常
解决方案:
后端(FastAPI):
@app.get("/api/articles", response_model=PaginatedResponse)
async def list_articles(page: int = 1, page_size: int = 20):
# 返回格式:{items: [...], total: 100, page: 1, page_size: 20, total_pages: 5}
return PaginatedResponse(...)
前端(Vue3 + Pinia):
// stores/article.js
const res = await articleApi.getList({ page: 1, page_size: 20 })
// 直接访问,因为后端返回PaginatedResponse而不是ApiResponse
this.articles = res.items || []
this.pagination = {
total: res.total || 0,
page: res.page || 1,
// ...
}
后端(Express):
res.json({
success: true,
data: { items: [...], total: 100 }
})
前端(React):
const res = await api.get('/articles')
// 需要访问 .data.data.items
setItems(res.data.data.items)
# 前后端API对接文档
## 服务地址
- 前端:http://localhost:5173
- 后端:http://localhost:8000
- API代理:/api -> http://localhost:8000/api
## API端点列表
### 文章列表
- **请求**:`GET /api/articles?page=1&page_size=20`
- **响应**:
- 格式:直接 `PaginatedResponse`
- 字段:`{items, total, page, page_size, total_pages}`
### 文章详情
- **请求**:`GET /api/articles/{id}`
- **响应**:
- 格式:`ApiResponse {code, message, data}`
- 数据在 `data` 字段中
## 数据结构
### 文章对象(列表)
```javascript
{
id: number,
title: string,
slug: string,
summary: string | null,
cover_image: string | null,
category: { id, name, slug } | null,
tags: [{ id, name, slug }],
author_name: string,
views: number,
published_at: string | null
}
## 注意事项
1. **响应格式不统一**:很多后端框架的列表接口直接返回分页数据,而详情接口返回包装格式
2. **日期格式**:后端通常返回ISO格式字符串,前端需要解析
3. **空值处理**:前端需要处理可能为null的字段
4. **错误处理**:确保拦截器正确处理HTTP错误状态
5. **类型安全**:使用TypeScript可以提前发现类型不匹配
## 工具推荐
- **API测试**:Postman, curl, HTTPie
- **网络抓包**:浏览器DevTools Network面板
- **文档生成**:FastAPI自动生成Swagger文档
- **类型检查**:TypeScript接口定义
testing
AI驱动的智能浏览器自动化工具。使用LLM理解页面并自动执行任务,比传统Playwright更智能、更省token。适用于复杂交互、动态页面、需要智能决策的浏览器操作。Chrome浏览器优先。
tools
网页登录态管理。使用 fast-browser-use (fbu) 管理各平台登录状态,定期检查可用性,新平台授权时自动保存 profile。
development
Monitor and report on API provider quotas, balances, and usage. Query official providers (Moonshot, DeepSeek, xAI, Google AI Studio) and relay/proxy providers (Xingjiabiapi, Aixn, WoW) via their billing APIs. Also checks subscription services (Brave Search, OpenRouter). Generates quota reports. Triggers on "查额度", "API余额", "quota check", "billing report", "api balance", "供应商额度", "中转站余额", "费用报告", "check balance", "how much credit".
development
# A股基金监控 Skill A股基金净值监控,支持实时估值和盘后净值,自动判断交易日/节假日。 ## 用法 ### 快速监控(命令行) ```bash # 默认配置,输出到控制台 bash ~/clawd/skills/a-fund-monitor/scripts/monitor.sh # 推送到群(使用--push参数) bash ~/clawd/skills/a-fund-monitor/scripts/monitor.sh --push # 监控指定基金 bash ~/clawd/skills/a-fund-monitor/scripts/monitor.sh --codes "000979 002943" ``` ### Agent调用 ``` 执行A股基金监控任务。 1. 读取配置文件: ~/clawd/skills/a-fund-monitor/config.json 2. 获取实时净值数据 3. 非交易日自动切换为简短报告 配置文件格式: { "funds": [ {"code": "000979", "name": "景顺长城沪港深精选股票