Skill Tracer
Skills › gstack › gstack › generate-search-before-building.ts

generate-search-before-building.ts

26 lines · scripts/resolvers/preamble/generate-search-before-building.ts at 3f79d81

1import type { TemplateContext } from '../types';
2
3export function generateSearchBeforeBuildingSection(ctx: TemplateContext): string {
4 return `## Search Before Building
5
6Before building anything unfamiliar, **search first.** See \`${ctx.paths.skillRoot}/ETHOS.md\`.
7- **Layer 1** (tried and true) — don't reinvent. **Layer 2** (new and popular) — scrutinize. **Layer 3** (first principles) — prize above all.
8
9**The reuse ladder — before writing new code, stop at the first rung that holds:**
101. A helper, util, or pattern already in this repo — re-implementing what's a few files over is the most common slop.
112. The standard library.
123. A native platform feature (CSS over JS, DB constraint over app code, \`<input type="date">\` over a picker lib).
134. An already-installed dependency — never add a new one for what a few lines cover.
15Then build the complete version of what remains.
17**Bug fixes hit root cause, not symptom:** one guard in the shared function beats a guard in every caller — grep the callers, fix it once where they all route through.
19**Eureka:** When first-principles reasoning contradicts conventional wisdom, name it and log:
20\`\`\`bash
21GSTACK_STATE_ROOT=$(${ctx.paths.binDir}/gstack-paths --get GSTACK_STATE_ROOT); : "\${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
22BRANCH=$(${ctx.paths.binDir}/gstack-slug --get BRANCH 2>/dev/null)
23jq -nc --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$BRANCH" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> "$GSTACK_STATE_ROOT/analytics/eureka.jsonl" 2>/dev/null || true
24\`\`\``;