gitwise
AGENTS.md1 starsChanged 4 months agoMITView on GitHub
gitwise is a Python CLI for optimizing git workflows and Claude Code integration. It uses rich for terminal rendering and applies modern git defaults, generates context files (CLAUDE.md, settings.json, skills), and manages AGENTS.md <-> CLAUDE.md coexistence (5-bucket model). For development, use uv to sync dependencies and run the package in place: For end-user installation (installs gitwise as a global CLI tool, isolated from your other Python environments): Windows users use install.ps1: The installer auto-installs uv if missing, then runs uv…
- Pipes a download into a shell
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,843 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository18 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- architecture-patternsSkill
- async-python-patternsSkill
- design-mdSkill
- python-anti-patternsSkill
- python-code-styleSkill
- python-configurationSkill
- python-design-patternsSkill
- python-error-handlingSkill
- python-observabilitySkill
- python-packagingSkill
- python-performance-optimizationSkill
- python-resource-managementSkill
- python-testing-patternsSkill
- python-type-safetySkill
- shellcheck-configurationSkill
- temporal-python-testingSkill
- uv-package-managerSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
17 rules. About 0 are common, 3 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 92
Never silence exceptions; try/except OSError only at I/O boundaries
- Distinctive: line 93
No comments describing what the code does -- only WHY (non-obvious invariants)
- Distinctive: line 94
No abstractions before 3+ concrete use cases (Rule of Three)
- Very specific: line 137
No unclosed resources; __exit__ / finally must run unconditionally
- Very specific: line 167
Before large commits: gitwise audit --quick.
- Very specific: line 172
Run uv run pytest after any change to setup_agents/ or its tests
- Very specific: line 173
Run ruff check and ruff format --check before committing
- Very specific: line 174
Use _safe_create_symlink for any new symlink creation (sandbox enforced)
- Very specific: line 175
Keep _plan_actions read-only (no write I/O) -- state detection reads are acceptable.
- Very specific: line 177
Verify doctor reports the venv Python version (3.12.x) when testing colors -- if it shows the system Python (3.14.x), colors will NOT work
- Distinctive: line 185
Create AGENTS.md in a target repo from scratch -- that's the user's content decision
- Very specific: line 186
Add external dependencies beyond the approved set to gitwise/.
- Very specific: line 189
Use Path.resolve() for symlink sandbox checks -- use os.path.realpath() instead
- Very specific: line 190
Commit without GPG (--no-gpg-sign is only allowed in test fixtures, never in real commits)
- Very specific: line 191
Add --global to npm config set or similar package manager globals
- Very specific: line 192
Run python -m gitwise without verifying it uses the venv Python (colors silently break if system Python is used)
- Very specific: line 193
Use gh pr merge --admin to bypass branch protection -- if a check fails, rerun the failed job (gh run rerun --job <id>) and wait for all …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
gitwise -- Agent Guide
gitwise is a Python CLI for optimizing git workflows and Claude Code integration. It uses rich for terminal rendering and applies modern git defaults, generates context files (CLAUDE.md, settings.json, skills), and manages AGENTS.md <-> CLAUDE.md coexistence (5-bucket model).
Dev Environment
For development, use uv to sync dependencies and run the package in place:
uv sync # create .venv and install rich + deps
uv run python -m gitwise <command> # run from repo root using the venvFor end-user installation (installs gitwise as a global CLI tool, isolated from your other Python environments):
bash install.sh # local: installs gitwise-cli via `uv tool install`
# or remote one-liner (macOS/Linux):
curl -fsSL https://raw.githubusercontent.com/drzioner/gitwise/main/install.sh | bashWindows users use install.ps1:
irm https://raw.githubusercontent.com/drzioner/gitwise/main/install.ps1 | iexThe installer auto-installs uv if missing, then runs uv tool install --upgrade gitwise-cli. The gitwise binary lands in ~/.local/bin (macOS/Linux) or %USERPROFILE%\.local\bin (Windows). See bash install.sh --help / Get-Help .\install.ps1 for options (--dry-run / -DryRun, --version=X.Y.Z / -Version).
Python resolution -- CRITICAL
bin/gitwise resolves the Python interpreter in this order:
.venv/bin/pythonin the project root (managed byuv, hasrichinstalled)- System
python3(fallback -- may NOT haverich)
Common pitfall: Running python -m gitwise from the terminal may invoke the SYSTEM Python (e.g., 3.14) which does NOT have rich installed. The try/except ImportError in output.py silently falls back to plain print() with zero colors. Always verify with python -m gitwise doctor -- if it reports the system Python version and shows no colors, the wrong interpreter is being used.
Correct invocation from repo root:
uv run python -m gitwise <cmd>-- guaranteed to use venv Python with richbin/gitwise <cmd>-- auto-detects.venv/bin/python, falls back topython3gitwise <cmd>(if installed) -- same asbin/gitwisevia symlink
Shell compatibility notes for AI agents:
- Claude Code's non-interactive shell does NOT source
~/.zshrc. Usepython -m gitwise(always works from repo root) or the fullgitwisepath if~/.local/binis on PATH. gwis a real binary (not just a shell alias) -- works in interactive terminals, non-interactive shells, and all AI agent Bash tools.gitwiseandpython -m gitwisealso work.settings.jsonallow list includesBash(gw *),Bash(gitwise *), andBash(python -m gitwise *).
Test Commands
uv run pytest # all tests (from repo root)
uv run pytest tests/test_setup_agents.py -v # single module
uv run pytest -k test_bucket2 # filter by name
uv run pytest --cov=gitwise # with coverageLint, Format & Type Check
ruff check gitwise/ tests/ # lint
ruff format gitwise/ tests/ # format
uv run basedpyright # type check (Python 3.10+, All platforms)
shellcheck install.sh bin/gitwise # shell lint
lefthook run pre-commit # run all pre-commit hooksProject Structure
See .agents/rules/project-structure.md for full tree.
Architecture Conventions
Each subcommand follows this pattern:
def run_<command>(...) -> int: # returns exit code
# 1. Validate (is_repo, repo_root)
# 2. Plan (_plan_actions -> list[dict], warnings, errors)
# 3. Dry-run: print plan, return 0
# 4. Confirm (unless --yes)
# 5. Execute (_execute_actions)
# 6. Return exit code (0=ok, 1=error, 2=strict warnings)See .agents/rules/setup-agents.md for setup_agents/ package internals and JSON schema.
Code Style
- Type hints on all function signatures (enforced by basedpyright)
pathlib.Pathoveros.path(useos.path.realpathfor symlink resolution --Path.resolve()can fail on broken symlinks)Literal["absent","regular","symlink_valid","symlink_broken"]for path states- Never silence exceptions;
try/except OSErroronly at I/O boundaries - No comments describing what the code does -- only WHY (non-obvious invariants)
- No abstractions before 3+ concrete use cases (Rule of Three)
T | NoneoverOptional[T](Python 3.10+ syntax)- Return types always explicit; never rely on inference for public APIs
- Named tuples or dataclasses over plain tuples for multi-value returns
- Constants as
SCREAMING_SNAKE_CASEat module level - Absolute imports only; no relative imports
- Functions: one purpose, max ~50 lines; extract when complexity grows
- Composition over inheritance; prefer protocols for interface definitions
- No
Anytype without explicit justification comment - Docstrings (PEP 257) on every public symbol: functions, classes, and
methods whose name does NOT start with
_(and dunder methods that are part of the public contract). One-line summary when the contract is obvious from the signature; add a second paragraph for non-obvious behavior, side effects, or the WHY behind a choice. Private helpers (_foo) may omit docstrings only when the name + body are self-documenting. Enforced externally: a "Docstring Coverage" check (reported on the PR's Pre-merge panel but NOT part of the repo CI) gates at >=80% of public symbols -- every PR must keep coverage above that line. - No "AI-tell" Unicode characters in docs, commit messages, or comments.
Forbidden: the section sign (U+00A7, the dual-S glyph used in legal-doc
style -- use the word "section" or just the heading name), smart quotes
(U+201C/U+201D double, U+2018/U+2019 single -- use straight ASCII), smart
apostrophes (U+2019 -- use
'), rightwards arrows (U+2192) in prose (use->or rewrite as a sentence), (U+2022)/(U+2605)/(U+2713)/(U+2717) as bullets (use-or*), and any emoji unless the user explicitly asks for them. These characters are the most reliable signal of AI-generated text, hurt readability on monospace renderers, and break copy-paste. Em dashes (--) are allowed only inside code comments where the project already uses them; in user-facing docs prefer--or a comma. Enforced byruff(where applicable) and by reviewer.
Error Handling
- Validate inputs early at function boundaries (fail-fast)
try/exceptonly at I/O boundaries; never bareexcept Exception: pass- Chain exceptions with
raise ... from eto preserve debug trail - Specific exception types (
ValueError,TypeError,FileNotFoundError) over genericException - Batch operations: track successes and failures separately; never abort entire batch on single item error
- Error messages: explain what failed, why, and how to fix
Resource Management
- Context managers (
with) for all file handles and external resources - No unclosed resources;
__exit__/finallymust run unconditionally subprocess.run()with explicittimeoutandcapture_output=Truefor git calls- Clean up temp files/dirs in
finallyblocks or fixture teardown
Git conventions for this project
- Diff:
git diff --statorgitwise summarize. Never rawgit diff. - Log:
git --no-pager log --oneline -n 20. Never without a limit. - Commits: conventional format
feat/fix/refactor/docs/chore: description. - Commits: always GPG-signed. Never
--no-gpg-sign. - Commits: breaking changes MUST include the
BREAKING CHANGEfooter (the marker word in caps followed by a colon and a description), or!after the type (e.g.feat!: ...). Without one of these markers,commitizenwill pick a patch bump even when the body mentions breaks, and the CHANGELOG entry generated by the auto-release workflow will not surface the break in### Breaking Changes. Withmajor_version_zero = true, a real breaking change should rotate the minor (e.g.0.22.x -> 0.23.0). - Commits: never write the exact
BREAKING CHANGE+ colon sequence in prose inside a commit body unless that commit really introduces a breaking change.commitizenscans the full message for the marker and fires a minor bump on any commit that contains it -- includingdocs:commits that merely document the convention. Backticks do NOT escape -- commitizen reads raw text. When you need to refer to the marker descriptively, omit the colon (writeBREAKING CHANGEalone) or use a placeholder likeBREAKING CHANGE [colon]. Avoid invisible Unicode tricks (no-break spaces, zero-width joiners) -- editors silently auto-format them back to regular characters. See thev0.23.0CHANGELOG entry for an example of what happens when this rule is violated. - Branch switch:
gitwise worktree new <branch>. Nevergit stash + checkout. - Changed files:
gitwise diff(=git diff --name-status HEAD). Never rawgit diff. - Before large commits:
gitwise audit --quick.
Boundaries
Always:
- Run
uv run pytestafter any change tosetup_agents/or its tests - Run
ruff checkandruff format --checkbefore committing - Use
_safe_create_symlinkfor any new symlink creation (sandbox enforced) - Keep
_plan_actionsread-only (no write I/O) -- state detection reads are acceptable; planning and execution are separate phases - Preserve JSON schema backward compat: v1 mandatory keys must remain
- Verify
doctorreports the venv Python version (3.12.x) when testing colors -- if it shows the system Python (3.14.x), colors will NOT work
Ask first:
- Adding a new subcommand (touches
_cli_parser.py+_cli_dispatch.pyand needs its own test module) - Changing the 5-bucket model logic in
setup_agents.plan._resolve_canonical_doc - Modifying
share/claude/templates (affects all repos that run setup-agents)
Never:
- Create AGENTS.md in a target repo from scratch -- that's the user's content decision
- Add external dependencies beyond the approved set to
gitwise/. Approved runtime deps are:rich(rendering),rich-argparse(argparse integration),shtab(shell completions). Any new dependency requires explicit review. - Use
Path.resolve()for symlink sandbox checks -- useos.path.realpath()instead - Commit without GPG (
--no-gpg-signis only allowed in test fixtures, never in real commits) - Add
--globaltonpm config setor similar package manager globals - Run
python -m gitwisewithout verifying it uses the venv Python (colors silently break if system Python is used) - Use
gh pr merge --adminto bypass branch protection -- if a check fails, rerun the failed job (gh run rerun --job <id>) and wait for all checks to pass before merging - Merge a PR that has any failing checks -- all checks must be green, no exceptions
- Iterate superficially when a CI step fails. Stop, read the actual traceback / failure log, identify the root cause, and apply ONE fix that addresses it. Each "ci(diag): ..." style commit that just adds another workaround is a smell -- by the third iteration, pause and re-analyze the whole problem from the logs. The verify-before-implement skill documents the Consult -> Analyze -> Verify -> Decide -> Implement loop; skipping Analyze produces the loop of reactive commits.
Scoped Rules
Detailed rules for specific subsystems are in .agents/rules/:
| File | Loads when editing |
project-structure.md | Always |
testing.md | tests/** |
setup-agents.md | gitwise/setup_agents/** |
color-system.md | gitwise/output.py, design.py, _runtime_config.py |
shell-scripts.md | bin/*, install.sh |
github-actions.md | .github/workflows/*, scripts/audit-template-injection.py |
python-cli.md | gitwise/__main__.py, gitwise/output.py, any CLI entry point or exception handler |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

