基于意图的提交 (Jīyú yìtú de tíjiāo)
Intent-Based Commits

原始链接: https://github.com/adamveld12/ghost

## Ghost:基于意图的Git提交 Ghost 是一款 CLI 工具,它通过关注*意图*而非代码变更来重新构想 Git 工作流。 你不是直接提交代码,而是提交*提示*——对你想要实现的目标的描述。 然后,一个 AI 编码代理(Claude、Gemini、Codex 或 OpenCode)生成代码,Ghost 将提示和生成的代码作为一个单元提交。 这会将你的 Git 历史记录转换为可读的设计决策日志,回答“我想要发生什么?” 而不是仅仅显示“发生了什么变化”。 由于保留了原始提示,每个提交都是可重现的,允许你在需要时重新生成代码。 主要功能包括:每次提交选择代理或设置默认值、用于预览更改的“dry-run”模式,以及详细的提交消息,其中包含提示、代理、模型和修改的文件。 Ghost 会智能地仅暂存已更改的文件,避免意外提交。 最终,Ghost 旨在将你的 Git 日志变成一份有价值的设计文档,以及项目演进的真实来源。

## 基于意图的提交记录,使用LLM - 黑客新闻总结 一个新的工具“基于意图的提交记录”(github.com/adamveld12) 旨在通过在提交信息中自动包含用于生成代码的精确提示,来改进LLM生成的代码审查。 其想法是提供上下文——让审查者能够理解更改背后的*意图*,并区分有意的代码和潜在的LLM“幻觉”。 一位用户利用Claude自动将提示添加到提交信息中,发现这有助于理解同事的LLM生成的工作。 讨论集中在它是否真正新颖(一些人认为它只是强化了良好的提交信息实践)以及结果的可重复性(即使使用相同的提示,LLM也不能保证产生相同的输出)。 虽然有些人质疑它的实际用途,但另一些人则认为在调试不清晰或文档记录不完善的代码时,访问提示具有潜在价值。
相关文章

原文

Commit intentions, not code.

Ghost is a CLI that flips the git workflow: instead of committing code, you commit prompts. An AI coding agent generates the artifacts; the commit captures both the intent and the output. Your git history becomes a chain of prompts + their results.

Supports claude, gemini, codex, and opencode — swap agents per-commit or set a default.

image

Code is ephemeral. Intent is permanent.

Every ghost commit answers: what did I want to happen here? Not what bytes changed. Each commit is reproducible from its prompt — if the code breaks, you have the exact instruction that generated it. The git log reads like a design document, not a diff summary.

git log --oneline

a3f2c1b  add JWT authentication middleware
7e91d4a  create user registration endpoint with email validation
2bc0f88  scaffold Express app with TypeScript and Prettier

Each of those is a ghost commit. Behind each message is an AI that turned words into working code, and a session ID that ties the output back to the generation.

you: ghost commit -m "add user auth with JWT"
     ↓
agent generates code → files written to working tree
     ↓
ghost detects changes → stages only new/modified files
     ↓
git commit with enriched message (prompt + agent + model + session + file list)

Ghost snapshots the working tree before and after the agent runs, diffs the two, and stages only what changed. Unrelated files are never touched.

git clone <this-repo>
export PATH="/path/to/ghost/bin:$PATH"

cd your-project
ghost init
ghost commit -m "create a REST API endpoint for user registration"
Command Description
ghost init Init git repo (if needed), install hook, create .ghost/ dir
ghost commit -m "prompt" Generate code from prompt, stage changed files, commit
ghost commit --agent gemini -m "prompt" Use a specific agent (claude, gemini, codex, opencode)
ghost commit --dry-run -m "prompt" Generate code, show what changed, don't commit
ghost log Pretty-print ghost commit history (prompt, agent, model, session, files)
GHOST_SKIP=1 ghost commit -m "..." Pass-through to plain git commit
# New feature (default agent: claude)
ghost commit -m "add a login page with email/password form and client-side validation"

# Use Gemini
ghost commit --agent gemini -m "refactor the database layer to use connection pooling"

# Use Codex
ghost commit --agent codex -m "fix the race condition in the payment processing queue"

# Use OpenCode
ghost commit --agent opencode -m "add OpenAPI documentation for all endpoints"

# With a specific model
ghost commit --agent claude --model claude-opus-4-6 -m "architect a microservices migration plan as code comments"

# Preview without committing
ghost commit --dry-run -m "add OpenAPI documentation for all endpoints"

# Set default agent via env
GHOST_AGENT=gemini ghost commit -m "scaffold a new service"

# Manual commit (bypass ghost entirely)
GHOST_SKIP=1 ghost commit -m "bump version to 1.2.0"

Every ghost commit has an enriched message body:

add a login page

ghost-meta
ghost-prompt: add a login page
ghost-agent: claude
ghost-model: claude-sonnet-4-6
ghost-session: 7f3a2b1c-4d5e-6f7a-8b9c-0d1e2f3a4b5c
ghost-files: src/pages/login.tsx,src/hooks/useAuth.ts,src/api/auth.ts
Field Description
ghost-meta Marker that identifies this as a ghost commit
ghost-prompt The exact prompt passed to the agent
ghost-agent The agent that generated the code (claude, gemini, codex, opencode)
ghost-model The model used by the agent
ghost-session UUID for this generation session
ghost-files Comma-separated list of files created or modified
Variable Description
GHOST_SKIP=1 Pass-through to plain git commit, no agent invocation
GHOST_AGENT=<agent> Default agent (overridden by --agent)
GHOST_MODEL=<model> Default model (overridden by --model)
Flag Description
--agent AGENT Agent for this commit (claude, gemini, codex, opencode)
--model MODEL Model override for the agent
--dry-run Generate code but do not stage or commit
  • git 2.x+
  • bash 4+
  • uuidgen (available on macOS and most Linux distros)
  • Agent CLI installed and configured for whichever agent(s) you use:

Why Intent-Based Commits?

Code is the artifact, intent is the source of truth.

When you read a traditional git log, you see what changed. With ghost, you see why — the actual human decision that triggered the change. A year from now, "refactor auth middleware to use dependency injection" tells you more than a diff ever will.

Every commit is reproducible. The prompt is preserved exactly. You can re-run any commit against a fresh checkout to see what Claude generates from the same instruction.

The log becomes a design document. Read ghost log top-to-bottom and you'll see the intent behind every architectural decision, not just the code that resulted from it.

Diffs show what the AI decided; messages show what you asked for. The two together give you full context: the goal and the implementation, inseparably linked.

The integration test spins up a temp git repo, runs a full ghost workflow including generating and compiling a C program, and verifies all metadata fields.

联系我们 contact @ memedata.com