Skip to content

Commit ad767cf

Browse files
committed
♻️ refactor(sdd): move prompt logic to .claude/skills/sdd.md skill file
1 parent 52debca commit ad767cf

File tree

2 files changed

+63
-50
lines changed

2 files changed

+63
-50
lines changed

.claude/skills/sdd.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SDD Pre-Analysis Skill
2+
3+
## ROLE — Read this first, before anything else
4+
5+
You are a **DOCUMENTATION ASSISTANT**. Your ONLY job is to create a branch and write analysis files under `.agent/`.
6+
7+
⛔ You MUST NOT modify any existing source file outside `.agent/`
8+
⛔ You MUST NOT apply any fix or implementation
9+
⛔ You MUST NOT open a Pull Request
10+
⛔ You MUST NOT push to protected branches: {protected_branches are passed in context}
11+
12+
## Steps
13+
14+
1. If a GitHub URL was provided, run: `gh issue view <url>` to fetch issue title and body.
15+
16+
2. Infer branch type from the issue/description:
17+
- Bug, crash, error, regression → `Fix` → base: `main`
18+
- New feature, enhancement → `Feat` → base: `develop`
19+
- Refactoring, cleanup → `Refactor` → base: `develop`
20+
- Documentation → `Docs` → base: `develop`
21+
- Everything else → `Chore` → base: `develop`
22+
If no `develop` branch exists remotely, use `main` for everything.
23+
24+
3. Determine base branch:
25+
Run: `git branch -r`
26+
Apply rule above. If the required base doesn't exist remotely, fall back to `main`.
27+
28+
4. Create branch from the correct base:
29+
```
30+
git fetch origin
31+
git checkout -b <branch-name> origin/<base-branch>
32+
```
33+
Branch naming:
34+
- Numbered issue: `{Type}/Issue{N}{DescriptionInPascalCase}` (e.g. `Feat/Issue5AddDarkMode`)
35+
- Free text: `{Type}/{DescriptionInPascalCase}` (e.g. `Fix/LoginCrashOnExpiredToken`)
36+
37+
5. Explore repo structure — focus on directories relevant to the issue.
38+
39+
6. Determine output directory from branch name:
40+
Branch `Feat/Issue5AddDarkMode``.agent/Feat/Issue5AddDarkMode/`
41+
Use this directory for ALL files in steps 7-9. Never write to a generic `.agent/planning/`.
42+
43+
7. Write `.agent/<Type>/<BranchSlug>/planning.md` — what to implement, acceptance criteria.
44+
45+
8. Write `.agent/<Type>/<BranchSlug>/files.md` — relevant files and their role.
46+
47+
9. Write `.agent/<Type>/<BranchSlug>/approach.md` — suggested approach, alternatives, tradeoffs.
48+
49+
10. Commit and push:
50+
```
51+
git add .agent/
52+
git commit -m "📝 docs(analysis): agregar pre-análisis <short description>"
53+
git push origin <branch-name>
54+
```
55+
56+
## End with a summary containing:
57+
- Branch name created and base branch used
58+
- Directory created under `.agent/` (full path)
59+
- Files written
60+
- One-line problem statement

src/bot/handlers/sdd_handler.py

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -108,60 +108,13 @@ def _build_sdd_prompt(
108108
else:
109109
issue_block = f"Issue / task description:\n{arg}"
110110

111-
prompt = f"""You are running a SDD pre-analysis on the repo at {working_dir}.
111+
return f"""SKILL: Load `.claude/skills/sdd.md` before starting.
112112
113-
Protected branches (NEVER push to these): {protected_str}
113+
Working directory: {working_dir}
114+
Protected branches (never push to these): {protected_str}
114115
115116
{issue_block}
116-
117-
Instructions:
118-
1. If a GitHub URL was provided, run: gh issue view {arg if is_url else '<url>'} to fetch the issue title and body.
119-
120-
2. Infer branch type from the issue/description content:
121-
- Bug report, crash, error, regression → Fix → base branch: main
122-
- New feature, enhancement, improvement → Feat → base branch: develop
123-
- Refactoring, cleanup → Refactor → base branch: develop
124-
- Documentation → Docs → base branch: develop
125-
- Everything else → Chore → base branch: develop
126-
If the repo does not have a "develop" branch, use "main" as the base for everything.
127-
128-
3. Determine the base branch:
129-
Run: git branch -r
130-
Use the branching rule above. If the required base branch does not exist remotely, fall back to main.
131-
132-
4. Create a new branch from the correct base:
133-
Run: git fetch origin
134-
Run: git checkout -b <branch-name> origin/<base-branch>
135-
Branch naming:
136-
- Numbered issues: {{Type}}/Issue{{N}}{{DescriptionInPascalCase}} (e.g. Feat/Issue5AddDarkMode)
137-
- Free-text input: {{Type}}/{{DescriptionInPascalCase}} (e.g. Fix/LoginCrashOnExpiredToken)
138-
139-
5. Explore the repo structure — focus on directories relevant to the issue.
140-
141-
6. Determine the output directory for this analysis using the branch name from step 4.
142-
The branch name (e.g. "Feat/Issue5AddDarkMode") maps directly to a subdirectory:
143-
- Branch "Feat/Issue5AddDarkMode" → .agent/Feat/Issue5AddDarkMode/
144-
- Branch "Fix/LoginCrashOnExpiredToken" → .agent/Fix/LoginCrashOnExpiredToken/
145-
Use this directory for ALL files in steps 7-9. Never write to a generic .agent/planning/ or .agent/context/.
146-
147-
7. Write .agent/<Type>/<BranchSlug>/planning.md — what to implement, acceptance criteria.
148-
8. Write .agent/<Type>/<BranchSlug>/files.md — relevant files and their role.
149-
9. Write .agent/<Type>/<BranchSlug>/approach.md — suggested approach, alternatives, tradeoffs.
150-
10. Run: git add .agent/ && git commit -m "📝 docs(analysis): agregar pre-análisis {arg[:60] if not is_url else 'issue #' + str(_extract_issue_number(arg) or '?')}"
151-
11. Run: git push origin <branch-name>
152-
12. RESTRICTIONS:
153-
- DO NOT modify any existing source file outside .agent/
154-
- DO NOT open a Pull Request
155-
- DO NOT run tests or builds
156-
- DO NOT push to any protected branch ({protected_str})
157-
158-
End with a brief summary containing:
159-
- Branch name created and base branch used
160-
- Directory created under .agent/ (full path)
161-
- Files written
162-
- One-line problem statement
163117
"""
164-
return prompt
165118

166119

167120
async def sdd_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:

0 commit comments

Comments
 (0)