Skip to content

Commit 087803e

Browse files
author
StackMemory Bot (CLI)
committed
feat(conductor): add --bare flag + typed prompt templates
- Replace --settings '{"hooks":{}}' with --bare flag (Claude Code 2.1.81) Skips hooks/LSP/plugins for faster agent spin-up - Add typed templates: implement-feature.md, fix-bug.md, write-tests.md with initialPrompt frontmatter (Claude Code 2.1.83) - Auto-select template by issue labels (bug→fix-bug, test→write-tests) - Templates use {{ISSUE_ID}}, {{TITLE}}, {{SCOPE}} placeholders - Falls back to custom template then default inline prompt
1 parent 260085c commit 087803e

4 files changed

Lines changed: 99 additions & 5 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
initialPrompt: true
3+
description: Fix a bug from a Linear ticket
4+
---
5+
You are fixing {{ISSUE_ID}}: {{TITLE}}
6+
7+
## Description
8+
{{DESCRIPTION}}
9+
10+
Labels: {{LABELS}}
11+
Priority: {{PRIORITY}}
12+
13+
{{PRIOR_CONTEXT}}
14+
15+
## Task
16+
1. **Reproduce**: Understand the bug from the description. Search for the failing code path.
17+
2. **Root cause**: Identify the exact cause — don't just patch symptoms.
18+
3. **Fix**: Apply the minimal fix.
19+
4. **Test**: Write a regression test that would have caught this bug.
20+
5. Run `npm run lint` and related tests.
21+
6. Commit: `fix({{SCOPE}}): {{TITLE}} ({{ISSUE_ID}})`
22+
23+
## Rules
24+
- Read before writing. Trace the bug through the call chain.
25+
- Do NOT refactor surrounding code — fix only.
26+
- If the bug is in a test, fix the test, not the code.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
initialPrompt: true
3+
description: Implement a new feature from a Linear ticket
4+
---
5+
You are working on {{ISSUE_ID}}: {{TITLE}}
6+
7+
## Description
8+
{{DESCRIPTION}}
9+
10+
Labels: {{LABELS}}
11+
Priority: {{PRIORITY}}
12+
13+
{{PRIOR_CONTEXT}}
14+
15+
## Task
16+
1. **Research phase**: Search the codebase to understand existing patterns, find related files, and verify assumptions BEFORE implementing.
17+
2. Implement the changes following existing patterns exactly.
18+
3. Write or update tests for new behavior.
19+
4. Run `npm run lint` to verify.
20+
5. Run related tests only (NOT full suite): `npx jest {relevant_pattern} --no-coverage`
21+
6. Commit: `feat({{SCOPE}}): {{TITLE}} ({{ISSUE_ID}})`
22+
23+
## Rules
24+
- Read before writing. Follow existing patterns.
25+
- Do NOT add Co-Authored-By lines.
26+
- Keep changes minimal — only what the ticket asks for.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
initialPrompt: true
3+
description: Add test coverage for existing code
4+
---
5+
You are adding tests for {{ISSUE_ID}}: {{TITLE}}
6+
7+
## Description
8+
{{DESCRIPTION}}
9+
10+
Labels: {{LABELS}}
11+
Priority: {{PRIORITY}}
12+
13+
{{PRIOR_CONTEXT}}
14+
15+
## Task
16+
1. **Read**: Understand the module under test — read the source file completely.
17+
2. **Identify**: List all public functions, branches, and edge cases.
18+
3. **Write tests**: Cover happy path, error cases, and edge cases.
19+
4. **Verify**: Run `npx jest {test_file} --no-coverage` and ensure all pass.
20+
5. Commit: `test({{SCOPE}}): add coverage for {{TITLE}} ({{ISSUE_ID}})`
21+
22+
## Rules
23+
- Use the project's existing test patterns (Jest + SWC, mock via DI).
24+
- Use global `jest` — do NOT import from `@jest/globals`.
25+
- `jest.clearAllMocks()` resets mocks — re-set in `beforeEach`.
26+
- ESLint: use `catch {}` not `catch (_err) {}`.
27+
- Tests should assert behavior, not just that functions exist.

src/cli/commands/orchestrator.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,11 +1846,10 @@ export class Conductor {
18461846
const claudeBin = this.findClaudeBinary();
18471847
const args = [
18481848
'-p',
1849+
'--bare',
18491850
'--output-format',
18501851
'stream-json',
18511852
'--dangerously-skip-permissions',
1852-
'--settings',
1853-
'{"hooks":{}}',
18541853
];
18551854
if (selectedModel) {
18561855
args.push('--model', selectedModel);
@@ -2312,16 +2311,32 @@ export class Conductor {
23122311
}
23132312
const priorContext = contextParts.join('\n');
23142313

2315-
// Try custom template first
2316-
if (existsSync(templatePath)) {
2314+
// Select template by issue type (labels or title heuristics)
2315+
const templateDir = join(__dirname, '..', '..', '..', 'scripts', 'conductor', 'templates');
2316+
const labelNames = issue.labels.map((l) => l.name.toLowerCase());
2317+
let templateName = 'implement-feature.md';
2318+
if (labelNames.includes('bug') || labelNames.includes('fix') || /\bfix\b|\bbug\b/i.test(issue.title)) {
2319+
templateName = 'fix-bug.md';
2320+
} else if (labelNames.includes('test') || labelNames.includes('coverage') || /\btest\b|\bcoverage\b/i.test(issue.title)) {
2321+
templateName = 'write-tests.md';
2322+
}
2323+
2324+
// Try typed template first, then custom template, then default
2325+
const typedTemplatePath = join(templateDir, templateName);
2326+
const selectedPath = existsSync(typedTemplatePath) ? typedTemplatePath : templatePath;
2327+
2328+
if (existsSync(selectedPath)) {
23172329
try {
2318-
let template = readFileSync(templatePath, 'utf-8');
2330+
let template = readFileSync(selectedPath, 'utf-8');
2331+
// Strip frontmatter (initialPrompt metadata)
2332+
template = template.replace(/^---[\s\S]*?---\n?/, '');
23192333
template = template
23202334
.replace(/\{\{ISSUE_ID\}\}/g, issue.identifier)
23212335
.replace(/\{\{TITLE\}\}/g, issue.title)
23222336
.replace(/\{\{DESCRIPTION\}\}/g, issue.description || '')
23232337
.replace(/\{\{LABELS\}\}/g, labels)
23242338
.replace(/\{\{PRIORITY\}\}/g, priority)
2339+
.replace(/\{\{SCOPE\}\}/g, issue.identifier.toLowerCase().replace(/-\d+$/, ''))
23252340
.replace(/\{\{ATTEMPT\}\}/g, String(attempt))
23262341
.replace(/\{\{PRIOR_CONTEXT\}\}/g, priorContext);
23272342
return template;

0 commit comments

Comments
 (0)