跪拜 Guibai
← All articles
Frontend · JavaScript · Artificial Intelligence

A Node Script That Writes Your Git Commits and Daily Standup Reports

By 阳火锅 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The tool turns two daily friction points — writing commit messages and standup summaries — into a background automation that costs pocket change. It sidesteps editor-config hell by avoiding prepare-commit-msg hooks entirely, and the idempotent report overwrite is a small but critical detail that prevents the kind of sloppy output that gets noticed in a performance review.

Summary

A developer fed up with writing daily reports and forgettable commit messages built a pair of Node scripts that offload both tasks to DeepSeek's cheap LLM. The first script stages changes, feeds the diff to the model, and commits after a terminal Y/N confirmation. The second runs via a post-commit hook, pulls all commits since midnight, and writes a structured Markdown report — overwriting any earlier version for the same day to avoid duplicates. Edge cases like special characters in messages, API failures, and Windows hook permissions are handled with pragmatic fallbacks: temp-file commits, manual-input degradation, and background execution so the hook never blocks a push. Total cost runs about five cents a day.

Takeaways
Staged diffs are fed to DeepSeek with both --stat and --unified=3 output so the model has overview and detail.
Commit messages are written to a temp file and committed with git commit -F to avoid shell-escaping bugs from quotes or dollar signs.
The post-commit hook runs the report script in the background (&) so commit latency stays near zero.
Daily reports overwrite any previous entry for the same date using a regex that matches the date header and all content until the next header or EOF.
API failures fall back to manual readline input so a rate limit or outage never blocks a commit.
DeepSeek pricing puts the daily cost at roughly ¥0.05 for 10 commits and 10 report generations.
Conclusions

Abandoning prepare-commit-msg in favor of a manual npm run commit command sidesteps the entire tangle of editor paths and IDE Git panel quirks — a reminder that Git hooks are often more fragile than a simple CLI prompt.

The idempotent report overwrite is the kind of detail that separates a tool that quietly works from one that generates embarrassing duplicate entries in front of a manager.

Using temperature 0.3 for commit messages and explicitly instructing the model not to explain itself are small prompt-engineering choices that prevent the most common LLM annoyances in structured output.

Concepts & terms
git commit -F
A Git command that reads the commit message from a file rather than the -m flag. It avoids shell-injection and escaping issues when the message contains quotes, dollar signs, or other special characters.
post-commit hook
A Git hook that runs automatically after a commit completes. Running the script in the background with & prevents the hook from blocking the terminal or delaying the next command.
temperature (LLM parameter)
A setting that controls randomness in model output. Lower values like 0.3 produce more deterministic, predictable text — useful for structured tasks like commit messages where creativity is unwanted.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗