Skip to main content

Generate AGENTS.md rules from agent failure logs

Project description

agentreflect

Generate AGENTS.md rules from AI coding agent failure logs. Closes the feedback loop in the agent quality trilogy.

Measure (coderace) → Generate (agentmd) → Guard (agentlint) → Learn (agentreflect)

What it does

Every developer using Claude Code or Codex has this problem: their agent makes a mistake, they fix it manually, update AGENTS.md, and hope it doesn't happen again. agentreflect automates the "update AGENTS.md" step.

Feed it failure logs → get targeted rule suggestions → apply them to your AGENTS.md.

In notes mode, agentreflect now prefers AGENTS-style operational rules over generic QA advice. If a note says the agent missed an exact routing target, skipped downstream verification after an irreversible action, or relied on fuzzy recall instead of exact facts already present in files, the suggestions will mirror that operating rule directly.

Install

pip install ai-agentreflect

For LLM-enhanced mode:

pip install 'ai-agentreflect[llm]'

Usage

From pytest output

# Capture failures
pytest --tb=short 2>&1 | tee failures.txt

# Generate suggestions
agentreflect generate --from-pytest failures.txt

From git log

agentreflect generate --from-git

Analyzes fix:, bug:, revert: commits and agent-related mistake commits.

From plain text notes

agentreflect generate --from-notes "agent forgot to check for None before accessing .value"
agentreflect generate --from-notes "fuzzy retrieval missed explicit facts already present in files; add an exact-match layer for handles and tool routing before semantic lookup"

Output formats

Markdown (default)

## agentreflect suggestions (2026-03-11)

### From: pytest failures (failures.txt)
- [ ] Always check for None before attribute access: use `if obj is not None` or `hasattr(obj, 'attr')`
- [ ] When catching AttributeError, log the object type with `type(obj).__name__`

_Source: 3 failures analyzed, 2 suggestions generated_

Diff format

agentreflect generate --from-pytest failures.txt --format diff

Outputs a unified diff ready to apply to AGENTS.md.

Apply directly

agentreflect generate --from-notes "agent used wrong variable" --apply AGENTS.md
# Asks for confirmation

agentreflect generate --from-pytest failures.txt --apply AGENTS.md --yes
# Applies without confirmation

LLM-enhanced mode

export ANTHROPIC_API_KEY=your_key_here
agentreflect generate --from-pytest failures.txt --llm

Uses claude-3-5-haiku-latest for contextual, specific suggestions tailored to your actual failures. Cost: ~$0.001 per analysis.

Basic pattern mode works without any API key.

Integration with the trilogy

Tool Role
coderace Measure agent output quality
agentmd Generate AGENTS.md from scratch
agentlint Guard/validate AGENTS.md rules
agentreflect Learn from failures → update rules

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

ai_agentreflect-0.2.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_agentreflect-0.2.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file ai_agentreflect-0.2.0.tar.gz.

File metadata

  • Download URL: ai_agentreflect-0.2.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for ai_agentreflect-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da93d55a71c29b47fa0b86388d9336d9f4e67413ed7b10e2e46d8be8c546301f
MD5 bd619033470d7d56c4b68d26ff4fa4e4
BLAKE2b-256 ca562003a3619d2fd79590da9c6841c36394ac58ed2bb70a949695178fa230d7

See more details on using hashes here.

File details

Details for the file ai_agentreflect-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_agentreflect-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88d053889ae8840957a67f4f1eafb4bf0bd670733c50cbb0b572353dca395f52
MD5 6e8e3b76b610f1bdff51498f280e32fb
BLAKE2b-256 c551088207310daf83f687d88cb317861ffd34d250a3492df93dcf87141a9054

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page