Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/skills/new-tool/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ argument-hint: <name> <one-line purpose>

Arguments: `$ARGUMENTS`. The first word is the new tool's name — written `<name>` below — and the rest is its one-line purpose. If either is missing, ask for it before starting.

The mise tasks and CI find modules by their `go.mod`, so none of them need editing. Everything below does.
The root mise tasks and CI find modules by their `go.mod`, so none of them need editing. Everything below does.

## 1. Module

- Create `<name>/go.mod` with `module <name>` and the same `go` line as the other modules. Copy the line from `cbz-fix/go.mod`; don't type a version.
- Copy `cbz-fix/mise.toml` to `<name>/mise.toml`, and add `"<name>"` to `[monorepo].config_roots` in the root `mise.toml`, alphabetically. Without them `mise deps --monorepo` skips the module, and the module-level tasks are missing.
- Write `<name>/main.go` in `package main`, following CLAUDE.md's *Common shape of each tool*. That means flags parsed in `main.go`, one-shot modes that return early, and every side effect behind an interface so tests can substitute fakes. If the tool keeps config, cache or state, put it in the app dir the way `mkv-movie/appdir.go` does.
- Add tests in the same piece of work, using `t.TempDir()` for the filesystem. Read an existing module's tests for the patterns first.

Expand Down
6 changes: 5 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ In a worktree, run `mise run` and these skills from the worktree directory, and

The tasks are declared in `mise.toml`. Each is a pair of scripts in `tasks/`: `<name>.sh` runs under `sh` on macOS and Linux, and `<name>.ps1` under `pwsh` on Windows, whatever shell `mise run` is typed in. Make every change to both. Every task but `clean`, `openapi` and `tmdb-openapi` takes module directory names and defaults to all of them.

The repo is a mise monorepo: the root `mise.toml` lists each module under `[monorepo].config_roots`, and each module's own `mise.toml` declares `[deps.go]` and includes `tasks/module.toml`. Inside a module, a bare task name means that module's task, so `mise run test` in `mkv-movie/` runs `mise run //:test mkv-movie`; reach a root task from there as `//:<task>`.

- `mise deps --monorepo` — `go mod download` in each module whose `go.mod`/`go.sum` changed. Run it in a fresh worktree.

- `mise run build [module...]` — build to `dist/<module>` (`dist/<module>.exe` on Windows).
- `mise run vet [module...]` — `go vet`, `go mod tidy -diff`, `golangci-lint run` and `golangci-lint fmt --diff` per module, for the Windows build on every OS (fails on unformatted files or an untidy `go.mod`/`go.sum`). The linters and formatters are configured in `.golangci.yml` and pinned in `mise.toml`; `mise install` provides them. Suppress a finding with `//nolint:<linter> // reason`, not staticcheck's `//lint:ignore`.
- `mise run vet-linux [module...]` — `GOOS=linux go vet ./...` and `GOOS=linux golangci-lint run ./...` per module, to type-check and lint the non-Windows stubs.
Expand Down Expand Up @@ -44,7 +48,7 @@ Six independent tools, each its own Go module (`package main`) with its own `go.

- **mkv-movie and mkv-tvshow duplicate a lot of code** (`rating.go`, `rating_cache.go`, `classification.go`, `set_rating.go`, `reset_rating.go`, `plex*.go` multi-account logic, `filetime*.go`, `appdir.go`). The copies have drifted; a bug fix in one usually needs porting to the other.
- **Other code is shared across tools, not just the twins**: `--clean` pruning, offline-drive detection and walk/stat error handling recur, and bugs in them have been fixed one tool at a time. Run the `twin-port-checker` agent after changing any tool; it checks both the twins and these shared shapes.
- The mise tasks find modules by their `go.mod`, so a new tool needs no task change. `/new-tool <name> <purpose>` scaffolds the module and covers the README, this file and the `configs/` junction.
- The mise tasks find modules by their `go.mod`; only `mise deps` and the module-level tasks need the module's own `mise.toml` and its `config_roots` entry. `/new-tool <name> <purpose>` scaffolds the module and covers those, the README, this file and the `configs/` junction.

Common shape of each tool:

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Build specific tools by directory name:
mise run build mkv-audit mkv-movie
```

Download every module's Go dependencies (each module runs `go mod download` only when its `go.mod` or `go.sum` changed):

```sh
mise deps --monorepo
```

Run all tests (or name modules, as for `build`):

```sh
Expand All @@ -51,6 +57,8 @@ Scan all modules for known vulnerabilities in their dependencies with
mise run vuln
```

Inside a module directory, `build`, `test`, `vet`, `vet-linux` and `vuln` act on that module alone; run a repo-wide task from there as `mise //:test`.

---

## cbz-fix
Expand Down
5 changes: 5 additions & 0 deletions cbz-fix/mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Each module is a monorepo config root (see the root mise.toml).
[deps.go]

[task_config]
includes = ["../tasks/module.toml"]
7 changes: 7 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# `mise deps --monorepo` installs each module's Go dependencies. List a new module here too.
monorepo_root = true

[monorepo]
config_roots = ["cbz-fix", "mkv-audit", "mkv-movie", "mkv-music", "mkv-tvshow", "sw-update"]
lockfile = true

[env]
# Error instead of downloading a newer Go when a go.mod's go line is ahead of the Go in use.
GOTOOLCHAIN = "local"
Expand Down
5 changes: 5 additions & 0 deletions mkv-audit/mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Each module is a monorepo config root (see the root mise.toml).
[deps.go]

[task_config]
includes = ["../tasks/module.toml"]
5 changes: 5 additions & 0 deletions mkv-movie/mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Each module is a monorepo config root (see the root mise.toml).
[deps.go]

[task_config]
includes = ["../tasks/module.toml"]
5 changes: 5 additions & 0 deletions mkv-music/mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Each module is a monorepo config root (see the root mise.toml).
[deps.go]

[task_config]
includes = ["../tasks/module.toml"]
5 changes: 5 additions & 0 deletions mkv-tvshow/mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Each module is a monorepo config root (see the root mise.toml).
[deps.go]

[task_config]
includes = ["../tasks/module.toml"]
5 changes: 5 additions & 0 deletions sw-update/mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Each module is a monorepo config root (see the root mise.toml).
[deps.go]

[task_config]
includes = ["../tasks/module.toml"]
23 changes: 23 additions & 0 deletions tasks/module.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Included by each module's mise.toml. In a monorepo a bare task name inside a module resolves to
# that module, so these run the root task for just this one: `mise run test` in mkv-movie/ is
# `mise run //:test mkv-movie`.

["build"]
description = "Build this module to dist/"
run = "mise run //:build {{ config_root | basename }}"

["test"]
description = "go test this module"
run = "mise run //:test {{ config_root | basename }}"

["vet"]
description = "Vet, tidy-check, lint and fmt-check this module"
run = "mise run //:vet {{ config_root | basename }}"

["vet-linux"]
description = "Type-check and lint this module's non-Windows stubs"
run = "mise run //:vet-linux {{ config_root | basename }}"

["vuln"]
description = "govulncheck this module (needs network)"
run = "mise run //:vuln {{ config_root | basename }}"