cocos-cli-build-automation-setup
Use when setting up a GUI-free CLI build pipeline for Cocos Creator 3.x.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when setting up a GUI-free CLI build pipeline for Cocos Creator 3.x.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when installing Cocos Creator 3.x and setting up a headless test bootstrap.
Use when building code-driven scrollable UI panels in Cocos Creator 3.x.
Use when code-driven UI nodes in Cocos Creator 3.x fail to render text or colors.
Use when Cocos Creator 3.x CLI build fails with scene or library errors.
Use when installing Cocos Creator 3.x and debugging scene import errors.
Use when creating a runtime test without a .scene file in Cocos Creator 3.x.
| name | cocos-cli-build-automation-setup |
| description | Use when setting up a GUI-free CLI build pipeline for Cocos Creator 3.x. |
Use this skill when:
npm run build) for a Cocos Creator 3.x projectbuilder.json — removing stale/dead scenes from the scenes arrayproject.json UUID mismatches (UUID set to placeholder strings like "main-scene")/Applications/Cocos/Creator/3.8.x/CocosCreator.app/.meta filesCocos projects may live in various paths. Search commonly:
find /Users -maxdepth 4 -type f -name "project.json" 2>/dev/null
Or use session_search to find past project path references.
cat profiles/v2/packages/builder.json
Check these items:
startScene — UUID must match MainScene.scene (or your actual main scene). Get the UUID from the .meta file:
cat assets/scenes/MainScene.scene.meta | grep uuid
scenes array — Should contain ONLY the scene you want to build. Remove:
Test_MeritForest, etc.)outputName — Set to a clean name like "wechatgame" (not "wechatgame-001", "-005")
Cocos Creator 3.x's project.json (at project root) may have placeholder UUIDs:
// ❌ BAD — "main-scene" is not a real UUID
"scenes": {
"db://assets/scenes/MainScene.scene": {
"uuid": "main-scene"
}
}
Fix with the real UUID from the .meta file:
// ✅ GOOD
"scenes": {
"db://assets/scenes/MainScene.scene": {
"uuid": "1f597e16-a4fc-43e1-bfb0-d8c96e240617"
}
}
Create a build script at the project root:
#!/bin/bash
set -e
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
COCOS_APP="/Applications/Cocos/Creator/3.8.8/CocosCreator.app/Contents/MacOS/CocosCreator"
echo "=== Build Start: $(date) ==="
# Verify CLI exists
if [ ! -f "$COCOS_APP" ]; then
echo "ERROR: Cocos Creator not found at $COCOS_APP"
exit 1
fi
# Run build
cd "$PROJECT_DIR"
"$COCOS_APP" --project . --build "platform=wechatgame"
if [ $? -ne 0 ]; then
echo "BUILD FAILED (exit code: $?)"
exit 1
fi
echo "=== BUILD SUCCESS: $(date) ==="
Make it executable:
chmod +x build-game.sh
Variations for other platforms:
"$COCOS_APP" --project . --build "platform=web-mobile""$COCOS_APP" --project . --build "platform=android""$COCOS_APP" --project . --build "platform=iphone"Add to package.json:
"scripts": {
"build": "bash build-game.sh",
"build:wechat": "bash build-game.sh",
"build:web": "bash build-game.sh web-mobile",
"test": "echo \"Error: no test specified\" && exit 1"
}
# Check builder.json
python3 -c "
import json
d = json.load(open('profiles/v2/packages/builder.json'))
print('startScene:', d['common']['startScene'])
print('scenes:', json.dumps(d['common']['scenes'], indent=2))
"
# Check project.json
python3 -c "
import json
d = json.load(open('project.json'))
print('startScene:', d.get('startScene'))
scenes = d.get('scenes', {})
if scenes:
print('scenes UUID:', list(scenes.values())[0]['uuid'])
"
Tell the user:
你以後只需要一行指令就搞掂:
npm run build
呢行指令會自動做:
1. ✅ 確認 Cocos Creator CLI 存在
2. ✅ 自動讀取 builder.json 配置
3. ✅ 用 MainScene 做 startScene 建置
4. ✅ 完成後顯示最新 build 目錄路徑
然後喺微信 DevTools 只需要 Cmd+R 刷新就得 — 完全唔使再開 Cocos Creator GUI!
The BuildTaskManager.taskMap section in builder.json contains old build task records. These don't affect the build output but can be confusing. They're safe to leave; the build will use the common section.
outputName can cause confusion old build folderIf outputName is "wechatgame-005" but user expects "wechatgame", the build output goes to a different folder. Always set outputName to a simple clean value.
Always verify COCOS_APP path exists before attempting a build. The path differs by version (3.8.8 vs 3.8.3 etc.).
If you need to fix a corrupted scene file, don't manually adjust __id__ array indices — Cocos uses them as internal pointers. Instead, rewrite the entire scene JSON or use the script-driven approach.
builder.json: startScene UUID matches MainScene.scene.metabuilder.json: scenes array has ONLY the main sceneproject.json: scene UUID is a real UUID (not "main-scene")build-game.sh exists and is executablepackage.json has "build" scriptnpm run build works end-to-end (run at least once)