Skip to content

Merge init and update into a single default command #2

@nirmalgupta

Description

@nirmalgupta

User Story

As a user of the code-context skill, I want a single /code-context command that does the right thing regardless of whether a context file already exists, so that I don't have to remember when to use init vs update and the mental model matches the reality that both commands already overlap heavily.

Acceptance Criteria

  • WHEN a user runs /code-context with no subcommand THEN the skill SHALL auto-detect project state and perform the correct action:
    • No code-context.md present → full generation (current init behavior)
    • code-context.md present with a valid <!-- code-context-marker: <hash> --> → git-diff-driven targeted update (current update behavior)
    • code-context.md present without a marker → full re-generation, preserving sections that still hold
  • WHEN a user runs /code-context <hint text> (where the first word is not a known subcommand) THEN the skill SHALL treat the entire argument as a focus hint for the merged command
  • WHEN a user runs /code-context init or /code-context update THEN the skill SHALL error with a clear migration message pointing to the unified command (e.g., "init and update have been merged — just run /code-context")
  • WHEN the merged command completes THEN the <!-- code-context-marker: ... --> SHALL be set to the current git rev-parse HEAD and the "Last updated" date SHALL be today's date
  • WHEN the merged command runs AND no CLAUDE.md "Code Context" section exists THEN the skill SHALL add it (same behavior as current init)
  • WHEN the CLAUDE.md snippet is written THEN it SHALL NOT reference the /code-context update (or any) subcommand name — the snippet SHALL describe the git-diff auto-update behavior inline so it stays correct regardless of future command renames
  • WHEN uninstall and global-uninstall are invoked THEN they SHALL continue to work unchanged

Implementation Phases

  • Phase 1: Refactor SKILL.md — collapse the Init Command and Update Command sections into a single default command with the three-way state detection; update Command routing to route unknown/empty first-word to the merged command and route init/update to an error stub
  • Phase 2: Rewrite claude-md-snippet.md to remove the /code-context update reference and describe the auto-update behavior inline (renaming-proof)
  • Phase 3: Update README.md — revise the Usage section to show the single command and remove init/update as separate entries; update any other prose that distinguishes init vs update
  • Phase 4: Update the skill frontmatter (description, argument-hint) in SKILL.md to reflect the new surface area

Risk Assessment

  • Technical risks: Users with older CLAUDE.md files (from prior installs) contain the old snippet referencing /code-context update. Their next session will try to auto-run it and hit the error stub. Mitigation: the error message must be unambiguous and mention that re-running /code-context once will rewrite CLAUDE.md with the new inline snippet. The command routing must catch this path cleanly.
  • Dependencies: None — self-contained change in this repo.
  • Unknowns: Whether we need a one-shot migration helper for old CLAUDE.md snippets, or whether the "run /code-context once to heal" flow is sufficient. Current plan: the latter.

Notes

Motivation: init and update already overlap — init reads and preserves an existing code-context.md, and update is really just an optimization that uses the git marker for targeted edits. Exposing both as separate verbs forces users to learn a distinction that the skill already handles internally. Collapsing to one command matches user intent ("bring my context file up to date with the current code") and is a cleanup refactor, not a feature change.

Design decisions captured in this issue (from the refinement discussion):

  • Default command (no subcommand) is the merged entry point
  • Auto-detects state via presence of file and marker
  • Old subcommands error out rather than aliasing — the user explicitly wanted a clean break
  • CLAUDE.md snippet drops any subcommand reference so it's rename-proof

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions