Set Focus
ตั้ง focus สำหรับงานใหม่ พร้อมสร้าง issue (GitHub หรือ Jira) ด้วย format มาตรฐาน
Usage
/focus [task description]
Pre-Feature Checklist (discipline, not ceremony)
ก่อนเริ่ม feature ใหม่ ทำ 3 ขั้นสั้นๆ (รวม ~5 นาที) แทนการ scaffold context pack เต็ม:
- Grep AP registry —
grep -i "<keyword>" kb/02-patterns/anti-patterns/registry.md(2-3 นาที)- ใช้ keyword จากงาน (bank account, gateway, websocket, ฯลฯ) เพื่อเช็คปัญหาเดิมที่เคยเจอ
- Verify data flow ในโค้ดจริง — grep handler → service → repository → gRPC/Kafka ก่อนเขียน spec (1-2 นาที)
- Spec/Plan ห้ามใช้ชื่อ file/function โดยไม่ verify — ใส่
file.go:123อ้างอิง
- Spec/Plan ห้ามใช้ชื่อ file/function โดยไม่ verify — ใส่
- อ่าน CLAUDE.md ของ repo ก่อนสร้าง infra files (migration, CI config, Dockerfile) — กัน convention drift
ถ้า task แตะ ≥ 2 repos + proto/schema หรือ security-critical → ลองใช้ [[Multi-Repo Feature Development]] §4.4 Validation Agents ก่อน merge
Instructions
Step 1: Check Current State
export TZ='Asia/Bangkok'
echo "=== Current Focus ==="
cat docs/current.md
echo ""
echo "=== Git Status ==="
echo "Branch: $(git branch --show-current)"
git status --short
Step 2: Handle Existing Focus
ถ้า STATE ไม่ใช่ ready หรือ completed:
มี focus อยู่แล้ว:
TASK: [current task]
STATE: [current state]
ต้องการ:
1. ทำต่องานเดิม (keep)
2. เปลี่ยนไปทำงานใหม่ (switch) - งานเดิมจะถูก mark เป็น pending
ถ้า user เลือก switch → เพิ่ม pending entry ใน docs/logs/activity.log
Step 3: Get Task from User
ถ้าไม่มี argument:
งานที่จะทำคืออะไร?
ถ้ามี argument → ใช้เป็น task description
Step 3.3: Check Language Setting
CURRENT_LANG=$(grep "^LANGUAGE:" docs/current.md 2>/dev/null | cut -d: -f2 | xargs)
echo "Current language: ${CURRENT_LANG:-not set}"
ถ้า LANGUAGE ยังไม่ได้ตั้งค่า (ไม่มี field หรือค่าเป็น -) ให้ถามผู้ใช้ด้วย AskUserQuestion:
ภาษาสำหรับ output (Language for generated output):
1. English (en)
2. ภาษาไทย (th)
เก็บค่าที่เลือกไว้ใช้ใน Step 7
ถ้ามีค่าอยู่แล้ว → ใช้ค่าเดิม ไม่ต้องถามซ้ำ
Step 3.5: Choose Issue Tracker
ใช้ AskUserQuestion เพื่อเลือก issue tracker:
ตรวจสอบ Jira config ก่อน:
if [[ -f ".jira-config" ]] || [[ -f "$HOME/.config/claude-km/jira.conf" ]]; then
echo "Jira: configured"
else
echo "Jira: not configured"
fi
ถ้ามี Jira config:
เลือก Issue Tracker:
1. GitHub Issues - สร้าง GitHub issue ใหม่
2. Jira - สร้าง Jira issue ใหม่
3. Jira (existing) - ดึง Jira issue ที่มีอยู่มาทำ
ถ้าไม่มี Jira config: ข้ามไป Step 4 (ใช้ GitHub เป็น default)
For Jira-specific paths (B and C), see jira-paths.md.
Language Setting
Check
LANGUAGEindocs/current.md. Ifth, translate output perreferences/language-guide.md. Seereferences/bash-helpers.mdfor detection snippet.
Path A: GitHub Issues (Default)
Step 4: Gather Issue Details
ใช้ AskUserQuestion เพื่อรวบรวมข้อมูลสำหรับ issue:
ถามข้อมูลต่อไปนี้:
-
Type: ประเภทของงาน
- feat (new feature)
- fix (bug fix)
- refactor (code restructure)
- docs (documentation)
- test (testing)
- chore (maintenance)
-
Overview: อธิบายสั้นๆ ว่างานนี้คืออะไร
-
Current State: สถานะปัจจุบันเป็นอย่างไร (ปัญหาที่เจอ, behavior เดิม)
-
Proposed Solution: วิธีแก้ไขที่เสนอ
-
Technical Details:
- Components ที่เกี่ยวข้อง
- Implementation approach
-
Acceptance Criteria: เกณฑ์การทดสอบ (อย่างน้อย 3 ข้อ)
- Specific testable criteria
- Performance requirements (ถ้ามี)
- UI/UX requirements (ถ้ามี)
Step 5: Create GitHub Issue
สร้าง GitHub issue ด้วย format มาตรฐาน:
export TZ='Asia/Bangkok'
gh issue create \
--title "[type]: [descriptive title]" \
--body "$(cat <<EOF
## Overview
[user input - brief description]
## Current State
[user input - what exists now]
## Proposed Solution
[user input - what should be implemented]
## Technical Details
- **Components affected:** [user input]
- **Implementation approach:** [user input]
## Acceptance Criteria
- [ ] [user input criteria 1]
- [ ] [user input criteria 2]
- [ ] [user input criteria 3]
---
## Session Info
- **Started:** $(date '+%Y-%m-%d %H:%M')
- **Branch:** [type]/[issue-number]-[short-slug]
- **Status:** In Progress
EOF
)"
เก็บ issue number ที่ได้ (เช่น #123) ไว้ใช้ใน Step 6
Step 5.5: Auto-assign Issue (GitHub)
อัตโนมัติ assign user ให้กับ issue:
ISSUE_NUMBER=[issue-number-from-step-5]
if gh issue edit "$ISSUE_NUMBER" --add-assignee @me 2>/dev/null; then
echo "Assigned issue #$ISSUE_NUMBER to you"
else
echo "Auto-assign skipped (already assigned or no permission)"
fi
ไปที่ Step 6: Create Feature Branch
Step 6: Create Feature Branch (Required)
ข้อบังคับ: ถ้าอยู่บน main, master, หรือ default branch ต้องสร้าง branch ใหม่เสมอ
export TZ='Asia/Bangkok'
CURRENT_BRANCH=$(git branch --show-current)
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
if [ -z "$DEFAULT_BRANCH" ]; then
if git show-ref --verify --quiet refs/heads/main; then
DEFAULT_BRANCH="main"
else
DEFAULT_BRANCH="master"
fi
fi
if [ "$CURRENT_BRANCH" = "main" ] || [ "$CURRENT_BRANCH" = "master" ] || [ "$CURRENT_BRANCH" = "$DEFAULT_BRANCH" ]; then
echo "Currently on $CURRENT_BRANCH - creating feature branch..."
git checkout -b "[type]/[issue-id]-[short-slug]"
echo "Created and switched to branch: [type]/[issue-id]-[short-slug]"
else
echo "Already on feature branch: $CURRENT_BRANCH"
fi
Branch Naming Convention:
| Type | Branch Prefix | GitHub Example | Jira Example |
|------|---------------|----------------|--------------|
| feat | feat/ | feat/123-add-auth | feat/PROJ-123-add-auth |
| fix | fix/ | fix/45-login-bug | fix/PROJ-45-login-bug |
| refactor | refactor/ | refactor/67-simplify | refactor/PROJ-67-simplify |
| docs | docs/ | docs/89-readme | docs/PROJ-89-readme |
Short slug rules:
- ใช้ lowercase
- แทนที่ space ด้วย
- - ตัดคำที่ไม่จำเป็นออก (a, an, the)
- จำกัดความยาวไม่เกิน 30 ตัวอักษร
Step 7: Update Files
Update docs/current.md:
For GitHub:
export TZ='Asia/Bangkok'
cat > docs/current.md << EOF
STATE: working
TASK: [task description from user]
SINCE: $(date '+%Y-%m-%d %H:%M')
ISSUE: #[issue-number]
BRANCH: [type]/[issue-number]-[short-slug]
LANGUAGE: [selected-language from Step 3.3, default: en]
EOF
For Jira:
export TZ='Asia/Bangkok'
cat > docs/current.md << EOF
STATE: working
TASK: [ISSUE_KEY] - [summary]
SINCE: $(date '+%Y-%m-%d %H:%M')
ISSUE: [ISSUE_KEY]
BRANCH: [type]/[ISSUE_KEY]-[short-slug]
JIRA_URL: https://[domain]/browse/[ISSUE_KEY]
LANGUAGE: [selected-language from Step 3.3, default: en]
PLAN: [path to plan file, if any]
EOF
Append to docs/logs/activity.log:
export TZ='Asia/Bangkok'
echo "$(date '+%Y-%m-%d %H:%M') | working | [task description] ([issue-id])" >> docs/logs/activity.log
Step 8: Jira Post-Setup (Jira only)
Transition to In Progress (if available):
./scripts/jira-client.sh transitions [ISSUE_KEY]
./scripts/jira-client.sh transition [ISSUE_KEY] [transition_id]
Assign to self:
./scripts/jira-client.sh assign [ISSUE_KEY] me
Step 9: Suggest Session Rename + Color
/renameและ/colorเป็น built-in commands — Claude เรียกเองไม่ได้ ต้องให้ user พิมพ์เอง ดังนั้นให้ปิดท้ายด้วยบรรทัดพร้อม copy-paste เสมอ (ห้ามข้าม)
เลือกสีตาม type:
| Type | Color |
|------|-------|
| feat | green |
| fix | red |
| refactor | purple |
| perf | orange |
| docs | blue |
| test | cyan |
| infra | yellow |
| chore | pink |
แสดงท้าย output (ปรับ session name ให้สั้น อ่านง่าย ขึ้นต้นด้วย issue id):
ตั้งชื่อ + สี session (copy วางได้เลย):
/rename [ISSUE-ID] [short task name]
/color [color-by-type]
Step 10: Confirm
For GitHub:
## Focus Set
**Issue Created:** #[issue-number]
**Title:** [type]: [title]
**Branch:** [type]/[issue-number]-[short-slug]
STATE: working
TASK: [task]
SINCE: [timestamp]
### Acceptance Criteria
- [ ] [criteria 1]
- [ ] [criteria 2]
- [ ] [criteria 3]
ตั้งชื่อ + สี session (copy วางได้เลย):
/rename #[issue-number] [short task name]
/color [color-by-type]
พร้อมเริ่มงาน! ใช้ `/td` เมื่อจบ session
For Jira:
## Focus Set
**Jira Issue:** [ISSUE_KEY]
**Summary:** [summary]
**URL:** https://[domain]/browse/[ISSUE_KEY]
**Branch:** [type]/[ISSUE_KEY]-[short-slug]
STATE: working
TASK: [ISSUE_KEY] - [summary]
SINCE: [timestamp]
Status: In Progress
Assigned to: you
ตั้งชื่อ + สี session (copy วางได้เลย):
/rename [ISSUE_KEY] [short task name]
/color [color-by-type]
พร้อมเริ่มงาน! ใช้ `/td` เมื่อจบ session
Issue Title Format
| Type | Prefix | Example |
|------|--------|---------|
| feature | feat: | feat: Add user authentication |
| bug fix | fix: | fix: Resolve login timeout |
| refactor | refactor: | refactor: Simplify auth middleware |
| docs | docs: | docs: Update API documentation |
| test | test: | test: Add unit tests for auth |
| chore | chore: | chore: Update dependencies |
Examples
# With argument
/focus Implement user authentication
# Without argument (will ask)
/focus
States Reference
| State | Meaning | Next Action |
|-------|---------|-------------|
| ready | ว่าง รอ task | /focus เพื่อตั้งงาน |
| working | กำลังทำ | /td เมื่อจบ |
| pending | รอทำต่อ | /recap แล้ว /focus |
| blocked | ติดปัญหา | แก้ปัญหาก่อน |
| completed | เสร็จแล้ว | /focus งานใหม่ |
Related Commands
| Command | Description |
|---------|-------------|
| /jira init | ตั้งค่า Jira credentials |
| /jira list | ดู Jira issues |
| /jira transitions | ดู transitions ที่ทำได้ |
| /td | จบ session + retrospective |
Scan to join WeChat group