{"slug": "assisted-by-print-an-assisted-by-harness-model-trailer-for-an-ai-agent-commit", "title": "assisted-by: print an Assisted-by: HARNESS:MODEL trailer for an AI agent commit, from the agent session record", "summary": "A developer published a script called assisted-by that prints an Assisted-by: trailer identifying the AI coding agent behind a commit, following the format documented by the Linux kernel. The tool reads the harness and model from the agent's own session record rather than the model's self-report, supports Claude Code and opencode, and exits silently when no agent session is found so commits get no trailer rather than a wrong one.", "body_md": "A script that prints an `Assisted-by:` trailer for the AI coding agent that runs it, in the format the [Linux kernel documents](https://docs.kernel.org/process/coding-assistants.html):\n\n```\nAssisted-by: HARNESS:MODEL [TOOL1] [TOOL2]\n```\n\nThe agent commits with it:\n\n```\nt=$(assisted-by); git commit ${t:+--trailer} ${t:+\"$t\"} -m \"Fix the thing\"\n```\n\nThe two-expansion form works in sh, bash, and zsh, and passes no `--trailer` when the script prints nothing.\n\nFor example:\n\n```\nAssisted-by: claude-code:claude-opus-5 spekk\n```\n\nIt reads the harness and the model from the agent's own session record, not from what the model says about itself. A model is not reliable about its own version, and no environment variable follows a model switch made in the middle of a session. When it finds no agent session or no model, it prints nothing and exits 1, so a commit gets no trailer rather than a wrong one.\n\nClaude Code and opencode are supported.\n\n```\nmkdir -p ~/.local/bin\ncurl -fsSL https://gist.githubusercontent.com/whusterj/01be8cde934ed45ea5264c30163d9cf5/raw/assisted-by -o ~/.local/bin/assisted-by\nchmod +x ~/.local/bin/assisted-by\ngit config --global trailer.assisted-by.ifExists addIfDifferent\n```\n\n`~/.local/bin` must be on your PATH. The `ifExists` entry keeps an amend or a rebase from adding a second copy of the trailer.\n\nThen tell your agent to use it. The rule in my agent instructions is: commit with the form above, never type the trailer or a tool name by hand, and if the script fails, commit without the trailer and say so.\n\nThe first version was a global `prepare-commit-msg` hook under `core.hooksPath`. Git resolves that setting by precedence, and a repository's own `core.hooksPath` wins. Husky sets one on purpose, and Claude Code writes one as a side effect when it creates a worktree, so the hook silently stopped in those repositories. The reverse also held: a global `core.hooksPath` hides a repository's `.git/hooks` for every hook name the global directory does not chain, so a pre-commit framework hook went quiet with no error. The trailer is a fact about the agent session, not about the repository, so the mechanism now lives with the agent.\n\n- It needs `python3` , and`sqlite3` for opencode.\n- A specialized tool is listed only when the environment is configured for it. `spekk` is listed when the binary is installed and the repository has a`specs/` directory. Add a tool by adding a check in the script, not by hand on the command line.\n- A commit you make yourself gets no trailer, because the script sees no agent session.\n- `git config assisted-by.enabled false` turns the trailer off for a repository, for commits and pull requests alike. Unset means on.\n- `assisted-by --pr` prints the same line for a pull request description, and only in a repository that has`git config assisted-by.pr true` . Unset means off, so a pull request carries no attribution by default.\n\nTurn off Claude Code's own `Co-authored-by` trailer in `~/.claude/settings.json`:\n\n```\n{\n  \"attribution\": {\n    \"commit\": \"\",\n    \"pr\": \"\"\n  }\n}\n```\n\n", "url": "https://wpnews.pro/news/assisted-by-print-an-assisted-by-harness-model-trailer-for-an-ai-agent-commit", "canonical_source": "https://gist.github.com/whusterj/01be8cde934ed45ea5264c30163d9cf5", "published_at": "2026-08-31 20:27:19+00:00", "updated_at": "2026-09-17 15:54:01.517989+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Claude Code", "opencode", "Linux kernel", "Git", "Husky", "spekk"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/assisted-by-print-an-assisted-by-harness-model-trailer-for-an-ai-agent-commit", "markdown": "https://wpnews.pro/news/assisted-by-print-an-assisted-by-harness-model-trailer-for-an-ai-agent-commit.md", "text": "https://wpnews.pro/news/assisted-by-print-an-assisted-by-harness-model-trailer-for-an-ai-agent-commit.txt", "jsonld": "https://wpnews.pro/news/assisted-by-print-an-assisted-by-harness-model-trailer-for-an-ai-agent-commit.jsonld"}}