動手建立「專案初始化器」Skill
曾慶良(阿亮老師) | AI 協作簡報實戰工作坊
建立一個 Skill,能自動產生:
只要說:
project-initializer/
├── SKILL.md
└── resources/
├── readme-template.md
├── gitignore-template.txt
└── package-template.json
# 在專案根目錄執行 mkdir -p .agent/skills/project-initializer/resources
建立完成後的路徑:
你的專案/
└── .agent/
└── skills/
└── project-initializer/
└── resources/
# 在專案根目錄執行 mkdir -p .claude/skills/project-initializer/resources
建立完成後的路徑:
你的專案/
└── .claude/
└── skills/
└── project-initializer/
└── resources/
---
name: project-initializer
description: "Initialize new projects with standard files. Triggers: init project, 初始化專案, create project, setup project, 建立專案. Creates: README.md, .gitignore, package.json with customized content."
---
# Project Initializer
This skill creates standard project files with customized content.
## Instructions
### Step 1: Gather Information
1. Ask user for the project name (MUST be lowercase, use hyphens for spaces)
2. Ask user for a brief project description (1-2 sentences)
### Step 2: Create README.md
1. Read the template from `resources/readme-template.md`
2. Replace `{{PROJECT_NAME}}` with the user's project name
3. Replace `{{PROJECT_DESCRIPTION}}` with the user's description
4. Write the result to `./README.md`
### Step 3: Create .gitignore
1. Read the template from `resources/gitignore-template.txt`
2. Write the content to `./.gitignore` (no modifications needed)
### Step 4: Create package.json
1. Read the template from `resources/package-template.json`
2. Replace `{{PROJECT_NAME}}` and `{{PROJECT_DESCRIPTION}}`
3. Write the result to `./package.json`
### Step 5: Report Completion
1. List all created files
2. Show a brief summary of what was set up
# {{PROJECT_NAME}}
{{PROJECT_DESCRIPTION}}
## 安裝
```bash
npm install
```
## 使用方式
```bash
npm start
```
## 開發
```bash
npm run dev
```
## 授權
MIT License
{{PROJECT_NAME}} 會被替換成專案名稱{{PROJECT_DESCRIPTION}} 會被替換成專案描述resources/readme-template.md
# Dependencies node_modules/ # Environment .env .env.local .env.*.local # Build dist/ build/ # System .DS_Store Thumbs.db # Logs *.log npm-debug.log* # IDE .vscode/ .idea/
{
"name": "{{PROJECT_NAME}}",
"version": "1.0.0",
"description": "{{PROJECT_DESCRIPTION}}",
"main": "index.js",
"scripts": {
"start": "node index.js",
"dev": "node --watch index.js",
"test": "echo \"No tests\" && exit 0"
},
"keywords": [],
"author": "",
"license": "MIT"
}
{{變數}} 要保留雙引號!
你的專案/
├── README.md ← 新建立
├── .gitignore ← 新建立
├── package.json ← 新建立
│
└── .claude/skills/project-initializer/
├── SKILL.md
└── resources/
└── ...
Skill 沒有被觸發
原因:description 的關鍵字不夠多
解法:加入更多觸發詞,中英文都加
YAML 格式錯誤
原因:冒號後沒空格、減號數量錯
解法:用 YAML 驗證器檢查
找不到模板檔案
原因:路徑或檔名大小寫錯誤
解法:確認路徑完全正確