Skip to content

Commands

คำสั่ง (Commands) คืออะไร

Section titled “คำสั่ง (Commands) คืออะไร”

คำสั่งที่กำหนดเอง ช่วยให้คุณสามารถสร้างชุดพรอมต์ที่ใช้บ่อยๆ เพื่อให้สามารถเรียกใช้งานได้อย่างรวดเร็วใน TUI

/my-command

การสร้างคำสั่ง

Section titled “การสร้างคำสั่ง”

สร้างไฟล์ Markdown ในไดเร็กทอรี commands/:

---
description: Run tests with coverage
agent: build
model: anthropic/claude-3-5-sonnet-20241022
---
Run the full test suite with coverage report and show any failures.
Focus on the failing tests and suggest fixes.

ใช้คำสั่งโดยพิมพ์ / ตามด้วยชื่อไฟล์ (ไม่รวมนามสกุล):

"/test"

ที่ตั้งไฟล์คำสั่ง

Section titled “ที่ตั้งไฟล์คำสั่ง”
  • ระดับผู้ใช้ (Global): ~/.config/opencode/commands/
  • ระดับโปรเจ็กต์: .opencode/commands/

ใช้ $ARGUMENTS หรือ $1, $2, $3 สำหรับอาร์กิวเมนต์ตำแหน่ง:

---
description: Create a new component
---
Create a new React component named $ARGUMENTS with TypeScript support.

รันคำสั่งพร้อมอาร์กิวเมนต์:

/component Button

ใช้ !command“ เพื่อแทรก output ของคำสั่ง bash:

---
description: Analyze test coverage
---
Here are the current test results:
!`npm test`
Based on these results, suggest improvements to increase coverage.

เอางานขึ้น git ด้วยคำสั่งเดียว

Section titled “เอางานขึ้น git ด้วยคำสั่งเดียว”
~/.config/opencode/push.md
---
description: Stage all changes, create a commit with a meaningful message based on the diff, and push to the current branch.
agent: build
---
Steps:
1. Run `git add .`
2. Analyze the diff and generate a concise commit message
3. Run `git commit -m "<generated-message>"`
4. Run `git push origin <current-branch>`
/push

Review code ที่กำลังจะ commit

Section titled “Review code ที่กำลังจะ commit”
~/.config/opencode/review.md
---
description: Review current git changes (Staged or Unstaged)
agent: build
---
1. Run `git status` to identify modified, added, or deleted files
2. Run `git diff` (for unstaged changes) or `git diff --cached` (for staged changes) to see the actual code changes
3. Analyze the changes for:
- Code quality and naming conventions
- Error handling and edge cases
- Security vulnerabilities
- Performance implications
- Potential bugs or issues
4. Provide constructive feedback and suggestions
/push

Mood Tracker - บันทึกอารมณ์ประจำวัน

Section titled “Mood Tracker - บันทึกอารมณ์ประจำวัน”
~/.config/opencode/mood.md
---
description: Log daily mood and activities
agent: reflect
---
Daily mood tracking:
1. Ask "How are you feeling today?" with options:
- 😊 Great
- 🙂 Good
- 😐 Okay
- 😔 Low
- 😢 Bad
2. Ask "What made you feel this way?" (optional)
3. Ask "What did you do today?" - work, exercise, social, etc.
4. Store the entry with timestamp in a local file:
- Format: `YYYY-MM-DD | mood | notes`
- Location: `~/.config/opencode/mood-log.md`
5. Show a simple weekly summary
/mood

Commands เป็นเครื่องมือที่ช่วยให้คุณสามารถสร้างชุดพรอมต์ที่ใช้บ่อยๆ ได้อย่างรวดเร็ว ช่วยเพิ่มประสิทธิภาพและความสม่ำเสมอในการทำงาน

Avatar whiteCat
ลองสร้างคำสั่งของคุณเองดูสิ! มันจะช่วยให้ workflow ของคุณเร็วขึ้นมาก

ทดสอบความเข้าใจเกี่ยวกับ Commands

ข้อ 1 / 50%

Commands ใน Opencode ทำหน้าที่อะไร?