worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

Tracking: rename creation hooks pre-start/post-start → pre-create/post-create

Open max-sixty opened this issue 6 months ago • 6 comments

Summary

Rename the worktree-creation hooks from pre-start/post-start to pre-create/post-create. post-start keeps confusing users ("start of what?", #1571). Hook names are protected interfaces (the wt.toml format and the wt hook CLI), so this ships as a staged deprecation rather than the breaking change already on the hooks/rename-start-to-create branch.

End state: -create canonical everywhere, -start accepted through a silent migration and then a warned one.

The semantic flip (main risk)

pre-create is a new name with no history. post-create is being reclaimed, and its meaning inverts: the old post-create was blocking (the pre-0.32.0 name for pre-start), the new one is background (an alias of post-start). A config still holding a stale post-create would flip from blocking to background silently. This is contained: post-create has been a fatal load error since 0.44.0, so by Phase 1 it will have been a hard error for roughly ten releases. The Phase 1 changelog states the flip plainly.

Plan

Releases land roughly weekly, so phases are paced in months.

  • Phase 1 (~June 2026): both names work, no warnings. -create becomes the canonical serde field; migrate_content() rewrites -start silently; docs and wt config update move to -create. The dead pre-0.32.0 post-create machinery is removed first.
  • Phase 2 (~September 2026): add deprecation warnings on config load and on wt hook pre-start/post-start, both pointing at wt config update.
  • Phase 3 (deferred): decide whether -start keeps migrating indefinitely, becomes a fatal error, or is removed.

Open decisions

  1. Bundle the post-create fatal-error removal into Phase 1 (default), or hold it one release longer.
  2. Cross-link #1571 now, and close it once its docs point lands in Phase 1.
  3. Phase 3 disposition.
History, current state, and Phase 1 implementation detail

History

This is the third naming move, and it partly reverses the second.

When Release Change
Before 0.32.0 Two creation hooks: post-create (blocking) and post-start (background).
0.32.0 #1679 Hooks reorganized into symmetric pre-/post- pairs. post-create renamed to pre-start, kept as a silently-migrated alias.
0.34.0 #1776 post-create removed from the docs.
2026-03-17 #1571 Issue filed: hook execution order is confusing and post-start is an unclear name.
0.44.0 #2361 post-create config key becomes a fatal load error. Clears the silent migration so the name can be reclaimed.
0.45.1 #2436 wt hook post-create CLI alias starts printing a deprecation warning.
0.52.0 (now) The actual rename never shipped. This issue resumes it.

Current state

  • Canonical: pre-start / post-start, across config keys, HookType, and wt hook subcommands.
  • post-create config key: fatal load error (POST_CREATE_REMOVED_MSG).
  • post-create CLI: wt hook post-create resolves to pre-start with a warning.
  • Dead machinery from the unfinished 0.32.0 cycle: HooksConfig::post_create and its folds, Deprecations::post_create, find_post_create_from_doc.
  • pre-create: never existed.

Phase 1 implementation

Prerequisite, same PR: remove the dead post-create machinery so the name is free.

Config:

  • pre-create/post-create become the canonical serde fields; rename HookType::PreStart/PostStart to PreCreate/PostCreate.
  • migrate_content() rewrites -start to -create, covering top-level keys, [hooks.*], [projects."id"] flattened and [projects."id".hooks], and the string, [table], and [[array-of-tables]] value forms.
  • wt config update and the startup warning both run off detect_deprecations(). Add the -start entry there so update finds it, but leave format_deprecation_warnings() silent until Phase 2.

CLI:

  • parse_hook_type and HOOK_TYPE_NAMES accept -create; -start stays accepted with no warning.

Docs:

  • Rewrite src/cli/mod.rs (the primary source), regenerate the docs/content/ and skills/worktrunk/reference/ mirrors, update README.md, the dev/*.example.toml files, and the JSON schema. Run cargo test --test integration test_docs_are_in_sync.
  • Per #1571, tighten the definition of when the hook fires.
  • The hooks/rename-start-to-create branch already has correct mechanical edits to reuse.

Checklist

Phase 1:

  • [ ] Remove dead post-create machinery
  • [ ] migrate_content() rewrite covering all config shapes
  • [ ] Canonical serde fields and HookType variants renamed
  • [ ] parse_hook_type / HOOK_TYPE_NAMES accept -create
  • [ ] Docs, examples, README, JSON schema updated
  • [ ] wt config update migrates -start with no startup warning
  • [ ] Changelog entry naming the semantic flip

Phase 2:

  • [ ] -start warning in format_deprecation_warnings()
  • [ ] CLI stderr warning for wt hook pre-start/post-start

Phase 3:

  • [ ] Decide keep, fatal, or remove

This was written by Claude Code on behalf of Maximilian Roos

max-sixty avatar May 20 '26 17:05 max-sixty

Image

Setting up post-create in the user config, yields this error on version 0.52.0. It suggests to rename post-create to pre-start, which makes little sense to me after reading this issue and the docs: https://worktrunk.dev/hook/#hook

EcksDy avatar May 21 '26 07:05 EcksDy

I'll release first thing tomorrow!

max-sixty avatar May 21 '26 08:05 max-sixty

actually — sorry — change of plan to make this problem less likely. I should have thought of this before

@worktrunk-bot:

  • let's revert the docs change
  • keep the code change — i.e. both Start and Create work
  • then in a couple of weeks, when everyone has had a change to update, then we'll switch the docs
  • then no one has the experience of @EcksDy , where the docs change before their version has changed

max-sixty avatar May 21 '26 14:05 max-sixty

Opened #2857 — docs continue to recommend pre-start/post-start; both names work in code (wt hook pre-create, [pre-create] configs, table and array-of-tables forms — all silent aliases). The pre-0.32.0 post-create fatal-load-error stays gone so [post-create] is valid TOML.

Once you're ready to flip the docs in a couple of weeks, most of the change is in src/cli/mod.rs's after_long_help and the doc-sync test propagates to the mirrors.

worktrunk-bot avatar May 21 '26 15:05 worktrunk-bot

Sorry this is a bit of mess.

On further reflection, pre-create & post-create are not good, because pre-create suggests "before creating the worktree", when we actually want "blocking, after creating worktree, before starting command"

I think start is not great, but can't think of ones that are that much better:

  • execute, but this runs even without --execute
  • init?
  • ready??

very open to ideas and feedback...

max-sixty avatar Jun 05 '26 02:06 max-sixty

Agreed pre-create is worse than pre-start — and I think it's worth naming why, because it rules out a whole family of candidates.

The trap: both hooks fire after the worktree exists. pre-start blocks before --execute/post-start; post-start runs in the background (lifecycle steps 4–5). So any verb that names the creation event makes pre- lie about timing. pre-create/pre-new/pre-init all read as "before the worktree is created," which is wrong. The pair isn't really symmetric around an event the way pre-merge/post-merge is — the only real difference between them is blocking vs. background.

Why start feels off: every other pair is anchored to a command the user types — wt merge, wt remove, wt switch, wt commit. There's no wt start. So it's the one pair with no verb behind it, hence "start of what?".

Two ways out:

  1. Anchor on the state the worktree reaches, not the creation event — ready:

    • pre-ready — blocking work that makes it ready (deps, env files), before the command runs
    • post-ready — background work kicked off once it's ready (dev server, watchers)

    This is the only option where pre-/post- is honest: the prep genuinely happens before "ready," the background work after. ready also reads well in prose ("runs once the worktree is ready").

  2. Keep start, sharpen the docs. It's arguably the most correct verb already — the work/session "starts" after both hooks — it's just vague out of context. Zero migration churn (we're mid-deprecation as it is), and #1571's ask was partly a docs-clarity fix anyway.

init is the familiar runner-up (everyone reads it as one-time new-thing setup, and devcontainers' postCreate/postStart are nearby prior art), but pre-init is slightly awkward since the blocking hook is the init.

My lean: ready if we're renaming, because it's the only scheme that makes the pre-/post- prefix tell the truth. Otherwise hold on start and just tighten the docs.

Happy to draft either once you pick.

worktrunk-bot avatar Jun 05 '26 03:06 worktrunk-bot