Codemend AI Skill
Codemend captures production JavaScript/TypeScript errors, analyzes them with AI, and generates fixes — either as GitHub PRs or paste-back prompts for AI coding tools like Lovable, Replit, and Cursor.
Tools
report_error
Report a production error to Codemend. The error will be analyzed by AI within seconds.
CODEBLOCK0
Response:
CODEBLOCK1
get_fix
Get the AI-generated fix for a reported error. Includes explanation, root cause, confidence score, and a fix prompt you can paste into your AI coding tool.
CODEBLOCK2
Response:
CODEBLOCK3
If the error is still being analyzed, the fix field will be null. Poll with check_status first.
check_status
Check if an error has been analyzed yet.
CODEBLOCK4
Response:
CODEBLOCK5
Statuses: new → analyzing → analyzed / fix_applied / INLINECODE7
list_errors
List recent errors for this project.
CODEBLOCK6
Response:
CODEBLOCK7
Setup in a Project
Browser (React, Next.js, Vue, etc.)
Add to your HTML <head>:
CODEBLOCK8
Or if using an AI coding tool (Lovable, Replit, Bolt, etc.), paste this prompt:
Add this error monitoring script to my app. Put it in the <head> section of index.html:
INLINECODE10
Node.js / Backend
CODEBLOCK9
CODEBLOCK10
Express
CODEBLOCK11
React Native
CODEBLOCK12
Typical Workflow
- 1. Set up error monitoring in your project (above)
- Errors are automatically captured and sent to Codemend
- Use
list_errors to see recent errors - Use
get_fix to get the AI-generated fix - Apply the fix: paste the
fix_prompt into your AI tool, or review the PR on GitHub
Codemend AI 技能
Codemend 捕获生产环境中的 JavaScript/TypeScript 错误,通过 AI 进行分析,并生成修复方案——既可以作为 GitHub PR 提交,也可以生成粘贴提示,供 Lovable、Replit 和 Cursor 等 AI 编码工具使用。
工具
report_error
向 Codemend 报告一个生产环境错误。AI 将在数秒内分析该错误。
bash
curl -X POST https://codemend.ai/api/errors/ingest \
-H Content-Type: application/json \
-d {
key: $CODEMENDAPIKEY,
message: TypeError: Cannot read properties of undefined (reading \map\),
stack: TypeError: Cannot read properties of undefined\n at renderList (src/components/List.tsx:15:23),
source_url: https://myapp.com/dashboard,
source_type: openclaw
}
响应:
json
{ status: queued, error_id: uuid-here }
get_fix
获取针对已报告错误的 AI 生成修复方案。包含解释、根本原因、置信度分数以及可粘贴到 AI 编码工具中的修复提示。
bash
curl -s https://codemend.ai/api/errors/{ERROR_ID}/fix \
-H x-api-key: $CODEMENDAPIKEY
响应:
json
{
error: {
id: uuid,
status: analyzed,
message: TypeError: Cannot read properties of undefined,
stack_trace: ...,
source_url: https://myapp.com/dashboard
},
fix: {
id: uuid,
explanation: map() 调用失败,因为首次渲染时 data 为 undefined,
root_cause: 数组操作前缺少空值检查,
confidence: 0.92,
fix_prompt: 在 src/components/List.tsx 中,如果 data 为 undefined,则添加提前返回...,
pr_url: https://github.com/user/repo/pull/42
},
dashboard_url: https://codemend.ai/errors/uuid
}
如果错误仍在分析中,fix 字段将为 null。请先使用 check_status 轮询。
check_status
检查错误是否已被分析。
bash
curl -s https://codemend.ai/api/errors/{ERROR_ID}/status \
-H x-api-key: $CODEMENDAPIKEY
响应:
json
{
status: analyzed,
message: TypeError: Cannot read properties of undefined,
has_fix: true,
fix_id: uuid-here,
dashboard_url: https://codemend.ai/dashboard/errors/uuid
}
状态:new → analyzing → analyzed / fix_applied / ignored
list_errors
列出该项目最近的错误。
bash
curl -s https://codemend.ai/api/errors?limit=10&status=analyzed \
-H x-api-key: $CODEMENDAPIKEY
响应:
json
{
errors: [
{
id: uuid,
status: analyzed,
message: TypeError: Cannot read properties of undefined,
source_type: openclaw,
has_fix: true,
fix_id: uuid,
created_at: 2026-03-11T12:00:00Z
}
],
total: 42
}
在项目中的设置
浏览器端(React、Next.js、Vue 等)
添加到 HTML 的
中:
html
或者,如果使用 AI 编码工具(Lovable、Replit、Bolt 等),粘贴以下提示:
将以下错误监控脚本添加到我的应用中。将其放在 index.html 的
部分:
Node.js / 后端
bash
npm install codemend
javascript
const codemend = require(codemend);
codemend.init({ apiKey: process.env.CODEMENDAPIKEY });
codemend.setupProcessHandlers();
Express
javascript
const codemend = require(codemend);
codemend.init({ apiKey: process.env.CODEMENDAPIKEY });
app.use(codemend.expressErrorHandler());
React Native
javascript
import codemend from codemend/react-native;
codemend.init({ apiKey: YOURAPIKEY });
codemend.setupErrorHandler();
典型工作流程
- 1. 在项目中设置错误监控(如上所述)
- 错误会被自动捕获并发送到 Codemend
- 使用 listerrors 查看最近的错误
- 使用 getfix 获取 AI 生成的修复方案
- 应用修复:将 fix_prompt 粘贴到 AI 工具中,或在 GitHub 上审查 PR