Skip to content

Commit 32e3da7

Browse files
Repo standardisation and DB layer simplification (#12)
# TLDR; Standardises repo infrastructure (Makefile, CI workflows, docs structure, agent config) and simplifies the DB layer by removing unnecessary Result wrapping from internal functions. # Details **What Was Added:** - New Claude skills: `code-dedup`, `spec-check`, `upgrade-packages` - Agent instruction files for Cursor, Windsurf, Copilot, Cline (all point to CLAUDE.md) - `opencode.json` config - `post-release` job in release workflow: auto-bumps `package.json` version and triggers website deploy - `deploy-pages.yml` replaces both `deploy-website.yml` (now `workflow_dispatch`) and `deploy.yml` (deleted) - Lock recovery spec section in `docs/specs/database.md` - Parsing strategy spec `[DISC-PARSE-STRATEGY]` in discovery docs - Mise task type added to README supported types table **What Was Changed:** - `Makefile` rewritten with cross-platform OS detection, help target, public/private target split, `fmt-check` target, and standardised interface - `CLAUDE.md` / `Agents.md` consolidated and restructured with logging standards, spec ID rules, and updated command table - `.gitignore` expanded with universal patterns and secret exclusions - `.prettierrc` renamed to `.prettierrc.json` with explicit settings - DB layer (`db.ts`, `lifecycle.ts`): `initSchema`, `registerCommand`, `ensureCommandExists`, `closeDatabase`, `addTagToCommand`, `removeTagFromCommand`, `getAllTagNames`, `getCommandIdsByTag`, `reorderTagCommands`, `getAllRows`, `upsertSummary` — all changed from `Result<T,E>` returns to direct returns (throw on unrecoverable errors only). New `getDbOrThrow()` convenience function replaces repeated `getDb()` + `Result` unwrapping - `CommandTreeProvider`, `QuickTasksProvider`, `TagConfig`, `extension.ts`, `TaskRunner`, `summaryPipeline` — simplified by removing `Result` unwrapping boilerplate, using `getDbOrThrow()` - CI workflow: `make format` replaces `make fmt-check` for the format step - Coverage thresholds updated to reflect current coverage levels - Docs moved from `docs/*.md` to `docs/specs/*.md` and `docs/plans/` - `release.yml` adds marketplace publish step and `post-release` job - VS Code workspace settings add title bar colour customisation - Lint fix: renamed `dbPath` parameter to `targetDbPath` in `dbLockRecovery.unit.test.ts` to resolve `no-shadow` error - README updated: 22 tool types, Mise added, text filter references removed **What Was Deleted:** - `.github/workflows/deploy.yml` (superseded by `release.yml` post-release job) - `.prettierrc` (replaced by `.prettierrc.json`) - `Result` wrapping removed from all internal DB functions that cannot meaningfully recover from errors - `/* istanbul ignore */` comments removed from DB functions that are now directly tested # How do the tests prove the change works - 84 unit tests pass (including `dbLockRecovery.unit.test.ts` lock removal tests, model selection, task runner param formatting, tree hierarchy, discovery, PowerShell parser) - 143 E2E tests pass covering: tree view click behaviour, folder hierarchy, make target line navigation, tag commands, junction table tagging, command runner (shell/npm/make/python/launch/vscode tasks), discovery (22 providers), configuration, quick tasks drag-and-drop, markdown preview, filtering, file utils, DB operations - 48 website Playwright tests pass (SEO, navigation, blog, docs, dark mode, responsive) - Coverage thresholds met (84.19% lines, 76.73% branches, 81.91% functions) --------- Co-authored-by: Jon Canning <jon.canning@gmail.com>
1 parent 23cafc2 commit 32e3da7

107 files changed

Lines changed: 2287 additions & 1570 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"Bash(npm run:*)",
1919
"Bash(npx cspell:*)",
2020
"Bash(gh pr:*)",
21-
"Bash(gh run:*)"
21+
"Bash(gh run:*)",
22+
"Bash(npm test:*)",
23+
"Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); t=d['total']; print\\(f\\\\\"Lines: {t['lines']['pct']}%\\\\nBranches: {t['branches']['pct']}%\\\\nFunctions: {t['functions']['pct']}%\\\\nStatements: {t['statements']['pct']}%\\\\\"\\)\")"
2224
]
2325
},
2426
"autoMemoryEnabled": false

.claude/skills/ci-prep/SKILL.md

Lines changed: 81 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,106 @@
11
---
22
name: ci-prep
3-
description: Prepare the codebase for CI. Reads the CI workflow, builds a checklist, then loops through format/lint/build/test/coverage until every single check passes. Use before submitting a PR or when the user wants to ensure CI will pass.
4-
argument-hint: "[optional focus area]"
5-
allowed-tools: Read, Grep, Glob, Edit, Write, Bash
3+
description: Prepares the current branch for CI by running the exact same steps locally and fixing issues. If CI is already failing, fetches the GH Actions logs first to diagnose. Use before pushing, when CI is red, or when the user says "fix ci".
4+
argument-hint: "[--failing] [optional job name to focus on]"
65
---
6+
<!-- agent-pmo:5547fd2 -->
77

8-
# CI Prep — Get the Codebase PR-Ready
8+
# CI Prep
99

10-
You MUST NOT STOP until every check passes and coverage threshold is met.
10+
Prepare the current state for CI. If CI is already failing, fetch and analyze the logs first.
1111

12-
## Step 1: Read the CI Pipeline and Build Your Checklist
12+
## Arguments
1313

14-
Read the CI workflow file:
14+
- `--failing` — Indicates a GitHub Actions run is already failing. When present, you MUST execute **Step 1** before doing anything else.
15+
- Any other argument is treated as a job name to focus on (but all failures are still reported).
16+
17+
If `--failing` is NOT passed, skip directly to **Step 2**.
18+
19+
## Step 1 — Fetch failed CI logs (only when `--failing`)
20+
21+
You MUST do this before any other work.
22+
23+
```bash
24+
BRANCH=$(git branch --show-current)
25+
PR_JSON=$(gh pr list --head "$BRANCH" --state open --json number,title,url --limit 1)
26+
```
27+
28+
If the JSON array is empty, **stop immediately**:
29+
> No open PR found for branch `$BRANCH`. Create a PR first.
30+
31+
Otherwise fetch the logs:
1532

1633
```bash
17-
cat .github/workflows/ci.yml
34+
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.[0].number')
35+
gh pr checks "$PR_NUMBER"
36+
RUN_ID=$(gh run list --branch "$BRANCH" --limit 1 --json databaseId --jq '.[0].databaseId')
37+
gh run view "$RUN_ID"
38+
gh run view "$RUN_ID" --log-failed
1839
```
1940

20-
Parse EVERY step in the workflow. Extract the exact commands CI runs. Build yourself a numbered checklist of every check you need to pass. This is YOUR checklist — derived from the actual CI config, not from assumptions. The CI pipeline changes over time so you MUST read it fresh and build your list from what you find.
41+
Read **every line** of `--log-failed` output. For each failure note the exact file, line, and error message. If a job name argument was provided, prioritize that job but still report all failures.
2142

22-
## Step 2: Coordinate with Other Agents
43+
## Step 2 — Analyze the CI workflow
2344

24-
You are likely working alongside other agents who are editing files concurrently. Before making changes:
45+
1. Find the CI workflow file. Look in `.github/workflows/` for `ci.yml`.
46+
2. Read the workflow file completely. Parse every job and every step.
47+
3. Extract the ordered list of commands the CI actually runs (e.g., `make fmt-check`, `make lint`, `make spellcheck`, `make test EXCLUDE_CI=true`, `make build`, `make package`).
48+
4. Note any environment variables, matrix strategies, or conditional steps that affect execution.
2549

26-
1. Check TMC status and messages for active agents and locked files
27-
2. Do NOT edit files that are locked by other agents
28-
3. Lock files before editing them yourself
29-
4. Communicate what you are doing via TMC broadcasts
30-
5. After each fix cycle, check TMC again — another agent may have broken something
50+
**Do NOT assume the steps.** Extract what the CI *actually does*.
3151

32-
## Step 3: The Loop
52+
## Step 3 — Run each CI step locally, in order
3353

34-
Run through your checklist from Step 1 in order. For each check:
54+
Work through failures in this priority order:
3555

36-
1. Run the exact command from CI
37-
2. If it passes, move to the next check
38-
3. If it fails, FIX IT. Do NOT suppress warnings, ignore errors, remove assertions, or lower thresholds. Fix the actual code.
39-
4. Re-run that check to confirm the fix works
40-
5. Move to the next check
56+
1. **Formatting** — run `make fmt` first to clear noise
57+
2. **Compilation errors** — must compile before lint/test
58+
3. **Lint violations** — fix the code pattern
59+
4. **Runtime / test failures** — fix source code to satisfy the test
4160

42-
When you reach the end of the checklist, GO BACK TO THE START AND RUN THE ENTIRE CHECKLIST AGAIN. Other agents are working concurrently and may have broken something you already fixed. A fix for one check may have broken an earlier check.
61+
For each command extracted from the CI workflow:
4362

44-
**Keep looping through the full checklist until you get a COMPLETE CLEAN RUN with ZERO failures from start to finish.** One clean pass is not enough if you fixed anything during that pass — you need a clean pass where NOTHING needed fixing.
63+
1. Run the command exactly as CI would run it.
64+
2. If the step fails, **stop and fix the issues** before continuing to the next step.
65+
3. After fixing, re-run the same step to confirm it passes.
66+
4. Move to the next step only after the current one succeeds.
4567

46-
Do NOT stop after one loop. Do NOT stop after two loops. Keep going until a full pass completes with every single check green on the first try.
68+
### Hard constraints
4769

48-
## Step 4: Final Coordination
70+
- **NEVER modify test files** — fix the source code, not the tests
71+
- **NEVER add suppressions** (`// eslint-disable`, `// @ts-ignore`)
72+
- **NEVER use `any` in TypeScript** to silence type errors
73+
- **NEVER delete or ignore failing tests**
74+
- **NEVER remove assertions**
4975

50-
1. Broadcast on TMC that CI prep is complete and all checks pass
51-
2. Release any locks you hold
52-
3. Report the final status to the user with the output of each passing check
76+
If stuck on the same failure after 5 attempts, ask the user for help.
77+
78+
## Step 4 — Report
79+
80+
- List every step that was run and its result (pass/fail/fixed).
81+
- If any step could not be fixed, report what failed and why.
82+
- Confirm whether the branch is ready to push.
83+
84+
## Step 5 — Commit/Push (only when `--failing`)
85+
86+
Once all CI steps pass locally:
87+
88+
1. Commit, but DO NOT MARK THE COMMIT WITH YOU AS AN AUTHOR!!! Only the user authors the commit!
89+
2. Push
90+
3. Monitor until completion or failure
91+
4. Upon failure, go back to Step 1
5392

5493
## Rules
5594

56-
- NEVER stop with failing checks. Loop until everything is green.
57-
- NEVER suppress lint warnings, skip tests, or lower coverage thresholds.
58-
- NEVER remove assertions to make tests pass.
59-
- Fix the CODE, not the checks.
60-
- If you are stuck on a failure after 3 attempts on the same issue, ask the user for help. Do NOT silently give up.
61-
- Always coordinate with other agents via TMC. Check for messages regularly.
62-
- Leave the codebase in a state that will pass CI on the first try.
95+
- **Always read the CI workflow first.** Never assume what commands CI runs.
96+
- Do not push if any step fails (unless `--failing` and all steps now pass)
97+
- Fix issues found in each step before moving to the next
98+
- Never skip steps or suppress errors
99+
- If the CI workflow has multiple jobs, run all of them (respecting dependency order)
100+
- Skip steps that are CI-infrastructure-only (checkout, setup-node, cache steps, artifact uploads) — focus on the actual build/test/lint commands
101+
102+
## Success criteria
103+
104+
- Every command that CI runs has been executed locally and passed
105+
- All fixes are applied to the working tree
106+
- The CI passes successfully (if you are correcting an existing failure)

.claude/skills/code-dedup/SKILL.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
name: code-dedup
3+
description: Searches for duplicate code, duplicate tests, and dead code, then safely merges or removes them. Use when the user says "deduplicate", "find duplicates", "remove dead code", "DRY up", or "code dedup". Requires test coverage — refuses to touch untested code.
4+
---
5+
<!-- agent-pmo:5547fd2 -->
6+
7+
# Code Dedup
8+
9+
Carefully search for duplicate code, duplicate tests, and dead code across the repo. Merge duplicates and delete dead code — but only when test coverage proves the change is safe.
10+
11+
## Prerequisites — hard gate
12+
13+
Before touching ANY code, verify these conditions. If any fail, stop and report why.
14+
15+
1. Run `make test` — all tests must pass. If tests fail, stop. Do not dedup a broken codebase.
16+
2. Run `make coverage-check` — coverage must meet the repo's threshold. If it doesn't, stop.
17+
3. Verify the project uses **static typing**. Check `tsconfig.json` has `"strict": true` — proceed.
18+
19+
## Steps
20+
21+
Copy this checklist and track progress:
22+
23+
```
24+
Dedup Progress:
25+
- [ ] Step 1: Prerequisites passed (tests green, coverage met, typed)
26+
- [ ] Step 2: Dead code scan complete
27+
- [ ] Step 3: Duplicate code scan complete
28+
- [ ] Step 4: Duplicate test scan complete
29+
- [ ] Step 5: Changes applied
30+
- [ ] Step 6: Verification passed (tests green, coverage stable)
31+
```
32+
33+
### Step 1 — Inventory test coverage
34+
35+
Before deciding what to touch, understand what is tested.
36+
37+
1. Run `make test` and `make coverage-check` to confirm green baseline
38+
2. Note the current coverage percentage — this is the floor. It must not drop.
39+
3. Identify which files/modules have coverage and which do not. Only files WITH coverage are candidates for dedup.
40+
41+
### Step 2 — Scan for dead code
42+
43+
Search for code that is never called, never imported, never referenced.
44+
45+
1. Look for unused exports, unused functions, unused classes, unused variables
46+
2. Check for `noUnusedLocals`/`noUnusedParameters` in tsconfig, look for unexported functions with zero references
47+
3. For each candidate: **grep the entire codebase** for references (including tests, scripts, configs). Only mark as dead if truly zero references.
48+
4. List all dead code found with file paths and line numbers. Do NOT delete yet.
49+
50+
### Step 3 — Scan for duplicate code
51+
52+
Search for code blocks that do the same thing in multiple places.
53+
54+
1. Look for functions/methods with identical or near-identical logic
55+
2. Look for copy-pasted blocks (same structure, maybe different variable names)
56+
3. Look for multiple implementations of the same algorithm or pattern
57+
4. Check across module boundaries — duplicates often hide in different packages
58+
5. For each duplicate pair: note both locations, what they do, and how they differ (if at all)
59+
6. List all duplicates found. Do NOT merge yet.
60+
61+
### Step 4 — Scan for duplicate tests
62+
63+
Search for tests that verify the same behavior.
64+
65+
1. Look for test functions with identical assertions against the same code paths
66+
2. Look for test fixtures/helpers that are duplicated across test files
67+
3. Look for integration tests that fully cover what a unit test also covers (keep the integration test, mark the unit test as redundant)
68+
4. List all duplicate tests found. Do NOT delete yet.
69+
70+
### Step 5 — Apply changes (one at a time)
71+
72+
For each change, follow this cycle: **change → test → verify coverage → continue or revert**.
73+
74+
#### 5a. Remove dead code
75+
- Delete dead code identified in Step 2
76+
- After each deletion: run `make test` and `make coverage-check`
77+
- If tests fail or coverage drops: **revert immediately** and investigate
78+
79+
#### 5b. Merge duplicate code
80+
- For each duplicate pair: extract the shared logic into a single function/module
81+
- Update all call sites to use the shared version
82+
- After each merge: run `make test` and `make coverage-check`
83+
- If tests fail: **revert immediately**
84+
85+
#### 5c. Remove duplicate tests
86+
- Delete the redundant test (keep the more thorough one)
87+
- After each deletion: run `make coverage-check`
88+
- If coverage drops: **revert immediately**
89+
90+
### Step 6 — Final verification
91+
92+
1. Run `make test` — all tests must still pass
93+
2. Run `make coverage-check` — coverage must be >= the baseline from Step 1
94+
3. Run `make lint` and `make fmt-check` — code must be clean
95+
4. Report: what was removed, what was merged, final coverage vs baseline
96+
97+
## Rules
98+
99+
- **No test coverage = do not touch.** If a file has no tests covering it, leave it alone entirely.
100+
- **Coverage must not drop.** The coverage floor from Step 1 is sacred.
101+
- **One change at a time.** Make one dedup change, run tests, verify coverage. Never batch.
102+
- **When in doubt, leave it.** If two code blocks look similar but you're not 100% sure they're functionally identical, leave both.
103+
- **Preserve public API surface.** Do not change function signatures, class names, or module exports that external code depends on.
104+
- **Three similar lines is fine.** Only dedup when the shared logic is substantial (>10 lines) or when there are 3+ copies.

0 commit comments

Comments
 (0)