Analyze repositories and synthesize AGENTS.md
Project description
agentskill
Analyze a code repository and synthesize an AGENTS.md that lets any agent produce code indistinguishable from the existing codebase.
What It Does
agentskill is not a linter and not a style guide generator. It is a forensic extraction tool. It walks a repository, measures every line, reads every config file, and inspects the commit log — then synthesizes a precise behavioral spec for a code-generating agent.
The output is not advice. It is mimicry instructions.
How It Works
Seven analyzers run in parallel. Each extracts one class of signal that an LLM cannot derive reliably from reading source files alone:
| Analyzer | What it measures |
|---|---|
scan |
Directory tree, file inventory, suggested read order |
measure |
Exact indentation, line length percentiles, blank line distributions |
config |
Formatter, linter, and type-checker detection with config excerpts |
git |
Commit prefixes, branch naming, merge strategy, signing |
graph |
Internal import graph, circular dependencies, most-depended modules |
symbols |
Symbol name extraction, naming pattern clustering, affix detection |
tests |
Test-to-source mapping, framework detection, fixture extraction |
Analyzer output feeds directly into AGENTS.md synthesis. The synthesis step follows the behavioral spec in SYSTEM.md.
Install
pip install agsk
This installs the agentskill CLI command.
For local development:
python -m pip install -e '.[dev]'
To enable the commit-time checks after installing the dev environment:
pre-commit install
Development Checks
Run the canonical local checks:
ruff format .
ruff check .
mypy
pytest
To verify formatting without rewriting files:
ruff format --check .
ruff check .
mypy
pytest
mypy is the repo's configured type-check command. Its configuration in
pyproject.toml covers agentskill/, scripts/, and tests/.
Optional commit-time hooks are available if you want them locally:
pre-commit install
pre-commit run --all-files
The pre-commit setup mirrors the lightweight formatting, lint, and type-check
passes. Full pytest runs remain part of normal local verification and CI.
Usage
# Canonical installed CLI
agentskill analyze <repo> --pretty
agentskill scan <repo> --pretty
agentskill measure <repo> --lang python --pretty
agentskill config <repo> --pretty
agentskill git <repo> --pretty
agentskill graph <repo> --pretty
agentskill symbols <repo> --pretty
agentskill tests <repo> --pretty
# Write output to file
agentskill analyze <repo> --out report.json
agentskill analyze <repo> --reference ../reference-repo --pretty
# Generate AGENTS.md markdown directly
agentskill generate <repo>
agentskill generate <repo> --out AGENTS.md
agentskill generate <repo> --reference ../ref-a --reference ../ref-b
agentskill generate <repo> --interactive
# Update or create AGENTS.md in place
agentskill update <repo>
agentskill update <repo> --section testing
agentskill update <repo> --exclude-section git
agentskill update <repo> --force
agentskill update <repo> --out updated-AGENTS.md
# Retained wrapper entrypoints for operator/skill workflows
python scripts/scan.py <repo> --pretty
python scripts/measure.py <repo> --lang python --pretty
The installed agentskill command is the steady-state CLI surface, including
local development after an editable install. The retained scripts/*.py
wrappers exist for direct analyzer execution and skill/operator workflows; they
are not the primary runtime surface.
The published console entrypoint is agentskill.main:main. The packaged
runtime under agentskill/ is the source of truth for subcommand behavior,
output contracts, generation, update flows, and reference handling.
Choosing analyze, generate, or update
Use analyze when you want machine-readable JSON from all analyzers and do not
want to touch any markdown files. This is the contract-stable inspection path.
Use generate when you want a fresh AGENTS draft from current analyzer output.
It prints markdown to stdout by default, never merges with an existing
AGENTS.md, and only writes a file when you pass --out.
Use update when you already have an AGENTS.md and want deterministic
regeneration plus preservation of untouched manual content. It writes back to
<repo>/AGENTS.md by default, or to --out while still using the repo-local
AGENTS.md as merge input.
Reference Workflow
Both analyze and generate accept repeatable --reference flags. References
are explicit inputs, not hidden priors.
- Every local reference must point to a directory with a readable
AGENTS.md. - Duplicate references are rejected instead of being silently counted twice.
analyze --referencevalidates references but does not change the JSON output shape.generate --referencepreserves reference order in the emitted metadata block so the provenance is inspectable.
Interactive Generation
generate --interactive is opt-in guided gap filling. It asks a small number of
targeted questions only when important signals are missing or ambiguous, then
injects those answers into the generated markdown as explicit interactive notes.
References can reduce prompt count when they clearly provide the missing convention. Conflicting references do not get auto-resolved; the command asks instead of guessing.
Update Workflow
agentskill update <repo> analyzes the repository, regenerates AGENTS sections,
merges them with any existing AGENTS.md, and writes the result back to
<repo>/AGENTS.md by default.
- Use
--sectionto regenerate only named sections. - Use
--exclude-sectionto keep generated sections untouched. - Missing targeted sections are inserted without rewriting unrelated manual sections.
- Untouched custom sections and preamble text stay in place in normal mode.
- Use
--forcefor a clean-slate rebuild that drops preserved/manual sections and ignores preservation hints from feedback.
Repo-Local Feedback
Incremental updates can read an optional repo-local sidecar file named
.agentskill-feedback.json. This file is explicit, version-controllable, and
affects only the current repository. It is not hidden memory and it is not
global learning.
{
"sections": {
"overview": {
"prepend_notes": [
"Mention that deployments go through GitHub Actions."
]
},
"testing": {
"pinned_facts": [
"Use pytest as the canonical test runner."
]
}
},
"preserve_sections": [
"red lines"
]
}
Supported feedback keys are intentionally narrow by design:
sections.<name>.prepend_notessections.<name>.pinned_factspreserve_sections
In normal update mode, preserve_sections acts like an implicit exclusion list.
In --force mode, those preservation hints are ignored so the command can
produce a true clean-slate rebuild.
Use .agentskill-feedback.json when you want durable, repo-local regeneration
guidance that should survive future updates. Edit AGENTS.md directly when you
are making one-off manual notes that should remain untouched unless you
explicitly target or force-regenerate that section.
Repository Structure
README.md # user-facing overview and contributor workflow
AGENTS.md # conventions for this repository itself
SYSTEM.md # synthesis spec for generated AGENTS.md files
SKILL.md # operational workflow used by the skill
pyproject.toml # packaging, CLI entrypoint, tool configuration
LICENSE
docs/
reference/ # packaged API reference for contributors
agentskill/
main.py # packaged CLI entry point — subcommand dispatch only
commands/ # analyzer implementations
lib/ # orchestration, output, update, generation helpers
common/ # shared low-level helpers and registries
scripts/
*.py # thin wrappers that import packaged analyzer entrypoints
tests/ # pytest suite for package code and wrapper behavior
references/
GOTCHAS.md # extraction and synthesis errors to avoid
examples/
README.md # language fixture index for analyzer validation
python/ # compact per-language analyzer fixtures
javascript/
typescript/
go/
rust/
java/
kotlin/
csharp/
c/
cpp/
ruby/
php/
swift/
objectivec/
bash/
mixed/
SINGLE_LANGUAGE.md # reference output: single-language repo
MULTI_LANGUAGE.md # reference output: multi-language single repo
MONOREPO.md # reference output: monorepo with multiple services
Where Code Goes
- Put packaged CLI and runtime code in
agentskill/. - Put analyzer implementations in
agentskill/commands/. - Put shared orchestration, generation, update, and output helpers in
agentskill/lib/. - Put reusable low-level helpers and registries in
agentskill/common/. - Keep
scripts/limited to thin wrappers and operator-facing workflow entrypoints. - Do not add analyzer or business logic to
scripts/. - Add tests in
tests/astest_<subject>.py; do not colocate tests underscripts/. - Keep root-level files focused on metadata, docs, and project-wide specs.
There is no separate steady-state runtime under scripts/, and there is no
root cli.py compatibility entrypoint to extend. New runtime behavior should
land in the package tree and then be exposed through agentskill.main if
it belongs on the public CLI.
Developer Workflow
For normal use and contributor verification:
python -m pip install -e '.[dev]'
agentskill analyze <repo> --pretty
ruff format .
ruff check .
mypy
pytest
When you add or extend functionality:
- Add analyzer logic in
agentskill/commands/when it maps to a command. - Add shared helpers in
agentskill/lib/oragentskill/common/, based on whether they are orchestration-level or low-level utilities. - Wire new CLI behavior through
agentskill/main.py. - Add a
scripts/*.pywrapper only when direct operator or skill invocation is still useful, and keep it as a thin import-and-dispatch shim. - Cover both packaged behavior and any retained wrapper behavior in
tests/.
For retained wrappers:
- Use
agentskill <command> ...as the canonical interface in docs and examples. - Use
python scripts/<name>.py ...only for direct analyzer wrappers that still exist. - Do not add
generateorupdatelogic toscripts/; those belong to the packaged CLI.
File Ecosystem
Three files govern behavior. Read all three before modifying anything.
| File | Role |
|---|---|
SYSTEM.md |
The canonical spec: what every section of AGENTS.md must contain and how to evaluate it |
SKILL.md |
The operational workflow: when to invoke, what scripts to run, in what order |
GOTCHAS.md |
Extraction and synthesis errors from previous runs — read before writing |
The public commands stay the same after refactors. The packaged runtime lives
under agentskill/, while scripts/ stays intentionally small as a
wrapper and operator layer for direct analyzer entrypoints.
Examples
The examples/ directory now serves two roles:
- Compact static language fixtures under per-language subdirectories for analyzer validation.
- Reference
AGENTS.mdexamples inSINGLE_LANGUAGE.md,MULTI_LANGUAGE.md, andMONOREPO.md.
If this skill was downloaded from ClawHub, or if examples/ is not present in the local copy, do not consult it; skip that step to avoid execution errors.
See examples/README.md for the supported fixture set.
API Reference
Static API reference for the packaged codebase lives under
docs/reference/:
docs/reference/cli.mdfor the packaged CLI entrypoint and dispatch modeldocs/reference/commands.mdfor analyzer command modulesdocs/reference/library.mdfor orchestration, generation, update, and reference helpersdocs/reference/common.mdfor low-level registries and filesystem helpers
The reference is contributor-oriented. It documents the packaged namespace and extension points that matter for real maintenance work without trying to expose every private helper as public API.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agsk-1.0.0.tar.gz.
File metadata
- Download URL: agsk-1.0.0.tar.gz
- Upload date:
- Size: 111.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50f9142cd0d5ef69cf360486916cfe52b128c2ba3ef9e9111cce5435ae474e09
|
|
| MD5 |
37daaeea7515ca64fd3e3c70975b2722
|
|
| BLAKE2b-256 |
2ccf6f09ee5a4875ae83388806d28f3ac69a52c870d25fabbdf23159c8aa966a
|
Provenance
The following attestation bundles were made for agsk-1.0.0.tar.gz:
Publisher:
release.yml on airscripts/agentskill
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agsk-1.0.0.tar.gz -
Subject digest:
50f9142cd0d5ef69cf360486916cfe52b128c2ba3ef9e9111cce5435ae474e09 - Sigstore transparency entry: 1429136753
- Sigstore integration time:
-
Permalink:
airscripts/agentskill@0046fd486c9f408463ca0d9dc259916e42c78de2 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/airscripts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0046fd486c9f408463ca0d9dc259916e42c78de2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agsk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: agsk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 74.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b585bc0e6a88799d955b5d4e0030e5cd55f6687c5848f97b7f3b2f62977952c1
|
|
| MD5 |
effff027e68055aaab5060fc69b25606
|
|
| BLAKE2b-256 |
b25f119b78476fda5e76e457d67684e4fa942545cb376abc224892d62f562a1a
|
Provenance
The following attestation bundles were made for agsk-1.0.0-py3-none-any.whl:
Publisher:
release.yml on airscripts/agentskill
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agsk-1.0.0-py3-none-any.whl -
Subject digest:
b585bc0e6a88799d955b5d4e0030e5cd55f6687c5848f97b7f3b2f62977952c1 - Sigstore transparency entry: 1429136759
- Sigstore integration time:
-
Permalink:
airscripts/agentskill@0046fd486c9f408463ca0d9dc259916e42c78de2 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/airscripts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0046fd486c9f408463ca0d9dc259916e42c78de2 -
Trigger Event:
push
-
Statement type: