Skip to content

Commit a144826

Browse files
committed
feat: tweak prompt
1 parent 735d7f8 commit a144826

File tree

1 file changed

+47
-33
lines changed
  • config/.claude/skills/cloudrun-development

1 file changed

+47
-33
lines changed

config/.claude/skills/cloudrun-development/SKILL.md

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ Use this skill for **CloudBase Run service development** when you need:
3939
- Access control: Only enable public network for Web scenarios; mini-programs prioritize internal direct connection, recommend closing public network
4040

4141
3. **Follow the workflow**
42-
- Initialize project → Check/generate Dockerfile (for container mode) → Local run (function mode only) → Configure access → Deploy → Verify
43-
- CloudBase run have a default preview url ends with `.run.tcloudbase.com`. If the project contain settings like CORS, allowHost or other config relative to the http origin. We should add this url too.
42+
- Initialize project → Check/generate Dockerfile (for container mode) → **⚠️ CHECK: CORS/Host/Origin config** → Local run (function mode only) → Configure access → Deploy → Verify
4443

4544
4. **Use tools correctly**
4645
- **Read operations**: `queryCloudRun` (list, detail, templates)
@@ -117,40 +116,53 @@ A concise guide for AI assistants and engineering collaboration, providing "when
117116

118117
2) **Initialize local project**
119118
- General: Use template `init` (both Function mode and Container mode can start from templates)
120-
- Container mode must "check or generate Dockerfile":
121-
- Node.js minimal example:
122-
```dockerfile
123-
FROM node:18-alpine
124-
WORKDIR /app
125-
COPY package*.json ./
126-
RUN npm ci --omit=dev
127-
COPY . .
128-
ENV NODE_ENV=production
129-
EXPOSE 3000
130-
CMD ["node","server.js"]
131-
```
132-
- Python minimal example:
133-
```dockerfile
134-
FROM python:3.11-slim
135-
WORKDIR /app
136-
COPY requirements.txt ./
137-
RUN pip install -r requirements.txt --no-cache-dir
138-
COPY . .
139-
ENV PORT=3000
140-
EXPOSE 3000
141-
CMD ["python","app.py"]
142-
```
143-
144-
3) **Local running** (Function mode only)
145-
- Automatically use `npm run dev/start` or entry file via `run`
146-
147-
4) **Configure access**
119+
- Container mode must "check or generate Dockerfile"
120+
- Check if the existed Dockerfile is suitable for CloudRun and user requirements
121+
- Decide whether to use the existed Dockerfile or Create a new one? You should not modify the original Dockerfile. But just create a dedicated one like `Dockerfile.cloudrun`
122+
- Node.js minimal example:
123+
```dockerfile
124+
FROM node:18-alpine
125+
WORKDIR /app
126+
COPY package*.json ./
127+
RUN npm ci --omit=dev
128+
COPY . .
129+
ENV NODE_ENV=production
130+
EXPOSE 3000
131+
CMD ["node","server.js"]
132+
```
133+
- Python minimal example:
134+
```dockerfile
135+
FROM python:3.11-slim
136+
WORKDIR /app
137+
COPY requirements.txt ./
138+
RUN pip install -r requirements.txt --no-cache-dir
139+
COPY . .
140+
ENV PORT=3000
141+
EXPOSE 3000
142+
CMD ["python","app.py"]
143+
```
144+
145+
Make sure the application are actually Running on the PORT.
146+
147+
3) **⚠️ CHECK: CORS / Host / Origin Configuration (CRITICAL)**
148+
- CloudBase Run provides a default preview URL ending with `.run.tcloudbase.com`
149+
- **MUST verify** backend CORS / `Access-Control-Allow-Origin` / `allowHost` allows `*.run.tcloudbase.com`
150+
- **Check locations** (common places):
151+
- CORS middleware configuration (e.g., `cors` package in Express)
152+
- `Access-Control-Allow-Origin` header settings
153+
- Framework-specific CORS configs (NestJS, FastAPI, Spring Boot, etc.)
154+
- Environment variables like `ALLOWED_ORIGINS`, `CORS_ORIGIN`
155+
- If using custom domain in production, ensure both custom domain AND `.run.tcloudbase.com` are allowed
156+
157+
4) **Local running** (Function mode only)
158+
159+
5) **Configure access**
148160
- Set `OpenAccessTypes` (WEB/VPC/PRIVATE) as needed; configure security domain and authentication for Web scenarios
149161

150-
5) **Deploy**
162+
6) **Deploy**
151163
- Specify CPU/Mem/instance count/environment variables, etc. during `deploy`
152164

153-
6) **Verify**
165+
7) **Verify**
154166
- Use `detail` to confirm access address and configuration meet expectations
155167

156168
### Example Tool Calls
@@ -178,10 +190,11 @@ A concise guide for AI assistants and engineering collaboration, providing "when
178190
{ "name": "manageCloudRun", "arguments": { "action": "run", "serverName": "my-svc", "targetPath": "/abs/ws/my-svc", "runOptions": { "port": 3000 } } }
179191
```
180192

181-
5) **Deploy**
193+
5) **Deploy** (⚠️ Confirm Step 3 CORS check completed)
182194
```json
183195
{ "name": "manageCloudRun", "arguments": { "action": "deploy", "serverName": "my-svc", "targetPath": "/abs/ws/my-svc", "serverConfig": { "OpenAccessTypes": ["WEB"], "Cpu": 0.5, "Mem": 1, "MinNum": 0, "MaxNum": 5 } } }
184196
```
197+
Make sure application are actually running on PORT that defined here.
185198

186199
6) **Create AI agent** (optional)
187200
```json
@@ -205,6 +218,7 @@ A concise guide for AI assistants and engineering collaboration, providing "when
205218
## 7. Quick Troubleshooting
206219

207220
- **Access failure**: Check OpenAccessTypes/domain/port, whether instance scaled down to 0
221+
- **CORS errors**: Backend must allow `*.run.tcloudbase.com` origin. See Step 3 in Core Workflow.
208222
- **Deployment failure**: Verify Dockerfile/build logs/image volume and CPU/Mem ratio
209223
- **Local running failure**: Only Function mode supported; requires `package.json` `dev`/`start` or entry `index.js|app.js|server.js`
210224
- **Performance jitter**: Reduce dependencies and initialization; appropriately increase MinNum; optimize cold start

0 commit comments

Comments
 (0)