Skip to content

Recommend /cdd-pre-pr after retrofit (#40), and fix cdd-state/cdd-worktree in non-interactive shells#42

Merged
drabaioli merged 3 commits into
mainfrom
gh_issue_40_pre_pr_after_retrofit
Jul 1, 2026
Merged

Recommend /cdd-pre-pr after retrofit (#40), and fix cdd-state/cdd-worktree in non-interactive shells#42
drabaioli merged 3 commits into
mainfrom
gh_issue_40_pre_pr_after_retrofit

Conversation

@drabaioli

@drabaioli drabaioli commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Started as #40 — make /cdd-pre-pr a recommended step in the retrofit flow, run in the retrofit worktree before opening its PR, so the retrofit's own edits (CDD-managed files, doc skeletons with unfilled placeholders) get the standard reconciliation + review pass.

Running that pre-PR pass on this very branch then surfaced a real defect, so the scope was extended to fix it: the shared cdd-worktree and cdd-state helpers didn't resolve in non-interactive shells — the case that matters for Claude Code's Bash tool, where the slash commands run cdd-state set …. A stock ~/.bashrc returns early for non-interactive shells (case $- in *i*), so the marker-guarded source line the installer adds never fires there and the functions are undefined — every state write silently no-oped. The fix drops thin PATH shims into ~/.local/bin (one per command); interactive shells still prefer the sourced function (functions shadow PATH), which preserves cdd-worktree's ability to cd the caller into the new worktree.

Changes

#40 — recommend /cdd-pre-pr after retrofit

  • .claude/commands/cdd-retrofit.md §3.4 + §5, process doc §6: name /cdd-pre-pr as the recommended step, run from a fresh session in the retrofit worktree, between "review the branch" and "open the PR" — both install and upgrade mode. Docs/command text only.

Extension — non-interactive shim fix

  • tools/cdd-worktree.sh, tools/cdd-state.sh: install step now writes executable PATH shims to ~/.local/bin, warns (doesn't mutate) when that dir isn't on PATH, regenerates idempotently.
  • doc/knowledge_base/claude-driven-development.md §2.8/§2.13, template/BOOTSTRAP.md: document the shim mechanism and why it is load-bearing for non-interactive cdd-state set.

Pre-PR reconciliation (this session)

  • Extended scripts/install-smoke-assert.sh to assert both helpers' shims are written, executable, and resolve+dispatch under a non-interactive PATH-only shell — satisfying the enforced "tested behaviour" practice for new script behaviour. Previously cdd-state install had no smoke coverage at all.
  • Added tools/cdd-state.sh to CI's bash -n and shellcheck sets (it was modified here but not linted in CI), with a scoped SC2016 disable on the intentional single-quoted jq filter.

Verification

All CDD gates green: shellcheck, command-drift, prompt-seam, install-smoke (with new shim assertions), worktree-resume, end-to-end template smoke, demo seed-overlay. The fix was also confirmed live — cdd-state set checks_passed resolved and ran from Claude Code's non-interactive Bash tool during this pre-PR session.

Closes #40

🤖 Generated with Claude Code

drabaioli and others added 3 commits July 1, 2026 16:13
…40)

Retrofit writes touch CDD-managed files and doc skeletons and can leave docs
inconsistent (e.g. a new skeleton doc shipped with unfilled placeholders).
Name /cdd-pre-pr as the recommended step, run from a fresh session in the
retrofit worktree, between reviewing the branch and opening the PR — in both
install and upgrade mode.

Process doc §6 isolation paragraph gets the recommendation; cdd-retrofit.md
§3.4 (install next-steps) and §5 (shared summary) name the step in their
printed next-steps. Docs/command text only — no roadmap, template, script,
or CI change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…shells

The self-installing helpers only wired a `source` line into ~/.bashrc, which a
stock rc skips for non-interactive shells via its `case $- in *i*` guard. Claude
Code's Bash tool is non-interactive, so `cdd-state set …` from the slash commands
was silently no-oping in every session — the state record never advanced past
what a human ran by hand.

Both installers now also drop thin PATH shims into ~/.local/bin (one per public
command) that source the helper and dispatch, so the commands resolve in any
shell. Interactive shells still prefer the sourced function (functions shadow
PATH), preserving cdd-worktree's caller-cwd change. Re-running install is
idempotent and regenerates the shims (newest wins).

Process-first consistency: process doc §2.8 (worktree install) and §2.13
(cdd-state) plus template/BOOTSTRAP.md now document the shim and why it is
load-bearing for the non-interactive case. No template copy of the helpers
exists, so this is a single-source change. All CI checks pass (install/resume
smoke, prompt-seam, command-drift).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pre-PR reconciliation for the PATH-shim change:
- Extend install-smoke-assert.sh to assert the cdd-worktree* and cdd-state
  shims are written to ~/.local/bin, executable, and resolve+dispatch under a
  non-interactive PATH-only shell (the case the shims exist for). Satisfies the
  enforced "tested behaviour" practice for new script behaviour.
- Add tools/cdd-state.sh to CI's bash -n and shellcheck sets (it was modified
  by this branch but not linted in CI), with a scoped SC2016 disable on the
  intentional single-quoted jq filter.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@drabaioli drabaioli changed the title Install PATH shims so cdd-state/cdd-worktree resolve in non-interactive shells Recommend /cdd-pre-pr after retrofit (#40), and fix cdd-state/cdd-worktree in non-interactive shells Jul 1, 2026
@drabaioli drabaioli merged commit 7548c29 into main Jul 1, 2026
1 check passed
@drabaioli drabaioli deleted the gh_issue_40_pre_pr_after_retrofit branch July 1, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make /cdd-pre-pr a standard step after /cdd-retrofit

1 participant