Skip to content

ktext install-hooks: automatically write agent session hooks #1

Description

@thegagne

Idea

After running ktext init, users still have to manually create .claude/settings.json (and equivalent files for other tools) to get automatic context loading at session start. This friction means most users probably won't do it.

A new subcommand could handle this:

ktext install-hooks claude       # write .claude/settings.json
ktext install-hooks cursor       # write .cursor/rules instruction line
ktext install-hooks copilot      # write .github/copilot-instructions.md instruction line
ktext install-hooks all          # write all of the above

What each would do

Claude Code — create or merge into .claude/settings.json:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup|compact",
        "hooks": [{ "type": "command", "command": "ktext export xml" }]
      }
    ]
  }
}

Other tools — append a single line to the instruction file if not already present:

Run `ktext export xml` at the start of every session to load project context.

Considerations

  • Should be idempotent — running twice doesn't duplicate entries
  • Should not overwrite existing hook config, only add to it (merge for JSON, append-if-absent for flat files)
  • Should print what it wrote and where
  • ktext init could prompt "install agent hooks now?" at the end as a natural follow-on step
  • Need to decide whether .claude/settings.json is the right target or whether .claude/settings.local.json (not committed) makes more sense for some users

Open questions

  • Should hooks be committed to the repo (shared with contributors) or local-only?
  • Is install-hooks the right name, or something like ktext setup or ktext integrate?
  • How do we handle tools that don't exist on the user's machine — skip silently or warn?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions