Catalog PyPI
PACKAGE EXPLORERView in registry

ai-agentreflect

PyPI

Generate AGENTS.md rules from agent failure logs

agent-qualityagentsagents.mdaiclaudecode-qualitycodex
Versions collected1
Direct dependencies4From release 0.3.0
Last observed21 Oct, 09:52 UTC

README

Version 0.3.0 documentation

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"

CI Integration

agentreflect ships a GitHub Action and a CI mode flag to integrate rule generation into your pull request workflow.

GitHub Action quick-start

# .github/workflows/agentreflect.yml
name: agentreflect
on: [pull_request]

jobs:
  learn:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: mikiships/agentreflect@v0.3.0
        with:
          mode: ci
          from-git: 'true'
          threshold: '10'   # fail PR if >= 10 new rules detected

CI mode (machine-readable output)

# Write JSON to stdout, summary to stderr
agentreflect generate --from-pytest failures.txt --ci

# Fail with exit 1 if >= 5 rules generated (useful for PR gates)
agentreflect generate --from-git --ci --fail-on 5

CI mode JSON output:

{
  "ci": true,
  "rules_count": 3,
  "rules_generated": 3,
  "source": "git log",
  "suggestions": [
    { "rule": "...", "rationale": "...", "confidence": 0.85, "category": "..." }
  ]
}

Full quartet pipeline

See .github/workflows/examples/agent-quality-pipeline.yml for a complete MEASURE → GENERATE → GUARD → LEARN pipeline running all four agent quality tools in sequence:

  1. agentlint — lint AGENTS.md for structural issues
  2. agentmd — check context file freshness
  3. coderace — review code changes
  4. agentreflect — extract new rules from failures

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

ToolRole
coderaceMeasure agent output quality
agentmdGenerate AGENTS.md from scratch
agentlintGuard/validate AGENTS.md rules
agentreflectLearn from failures → update rules

License

MIT

Downloads & popularity

1downloads
1-day window · source-reported counts20 Oct 2026
1680
2026-07-23: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-07-23–2026-07-232026-07-24: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-07-24–2026-07-242026-07-26: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-07-26–2026-07-262026-07-27: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-07-27–2026-07-272026-07-30: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-07-30–2026-07-302026-08-01: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-01–2026-08-012026-08-02: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-02–2026-08-022026-08-08: 4 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-08–2026-08-082026-08-09: 3 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-09–2026-08-092026-08-10: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-10–2026-08-102026-08-14: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-14–2026-08-142026-08-15: 3 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-15–2026-08-152026-08-17: 3 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-17–2026-08-172026-08-19: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-19–2026-08-192026-08-21: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-21–2026-08-212026-08-23: 3 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-23–2026-08-232026-08-24: 5 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-24–2026-08-242026-08-25: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-25–2026-08-252026-08-28: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-28–2026-08-282026-08-31: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-08-31–2026-08-312026-09-01: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-01–2026-09-012026-09-06: 6 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-06–2026-09-062026-09-07: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-07–2026-09-072026-09-15: 7 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-15–2026-09-152026-09-16: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-16–2026-09-162026-09-20: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-20–2026-09-202026-09-21: 6 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-21–2026-09-212026-09-22: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-22–2026-09-222026-09-23: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-23–2026-09-232026-09-26: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-26–2026-09-262026-09-27: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-27–2026-09-272026-09-28: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-28–2026-09-282026-09-29: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-29–2026-09-292026-09-30: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-09-30–2026-09-302026-10-01: 6 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-01–2026-10-012026-10-02: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-02–2026-10-022026-10-06: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-06–2026-10-062026-10-08: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-08–2026-10-082026-10-09: 4 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-09–2026-10-092026-10-10: 4 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-10–2026-10-102026-10-12: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-12–2026-10-122026-10-13: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-13–2026-10-132026-10-14: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-14–2026-10-142026-10-15: 7 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-15–2026-10-152026-10-16: 16 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-16–2026-10-162026-10-17: 11 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-17–2026-10-172026-10-18: 2 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-18–2026-10-182026-10-19: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-19–2026-10-192026-10-20: 1 · observed 2026-10-21T10:28:28.8028566Z · period 2026-10-20–2026-10-20
23 Jul20 Oct

pypistats · 49 observations shown. Missing days are unknown. Source category: overall: without mirrors.

View observed values
Date / source periodValueObserved at
2026-10-20 – 2026-10-2012026-10-21T10:28:28.8028566Z
2026-10-19 – 2026-10-1912026-10-21T10:28:28.8028566Z
2026-10-18 – 2026-10-1822026-10-21T10:28:28.8028566Z
2026-10-17 – 2026-10-17112026-10-21T10:28:28.8028566Z
2026-10-16 – 2026-10-16162026-10-21T10:28:28.8028566Z
2026-10-15 – 2026-10-1572026-10-21T10:28:28.8028566Z
2026-10-14 – 2026-10-1412026-10-21T10:28:28.8028566Z
2026-10-13 – 2026-10-1312026-10-21T10:28:28.8028566Z
2026-10-12 – 2026-10-1222026-10-21T10:28:28.8028566Z
2026-10-10 – 2026-10-1042026-10-21T10:28:28.8028566Z
2026-10-09 – 2026-10-0942026-10-21T10:28:28.8028566Z
2026-10-08 – 2026-10-0812026-10-21T10:28:28.8028566Z
2026-10-06 – 2026-10-0612026-10-21T10:28:28.8028566Z
2026-10-02 – 2026-10-0212026-10-21T10:28:28.8028566Z
2026-10-01 – 2026-10-0162026-10-21T10:28:28.8028566Z
2026-09-30 – 2026-09-3012026-10-21T10:28:28.8028566Z
2026-09-29 – 2026-09-2912026-10-21T10:28:28.8028566Z
2026-09-28 – 2026-09-2822026-10-21T10:28:28.8028566Z
2026-09-27 – 2026-09-2712026-10-21T10:28:28.8028566Z
2026-09-26 – 2026-09-2612026-10-21T10:28:28.8028566Z
2026-09-23 – 2026-09-2322026-10-21T10:28:28.8028566Z
2026-09-22 – 2026-09-2212026-10-21T10:28:28.8028566Z
2026-09-21 – 2026-09-2162026-10-21T10:28:28.8028566Z
2026-09-20 – 2026-09-2022026-10-21T10:28:28.8028566Z
2026-09-16 – 2026-09-1612026-10-21T10:28:28.8028566Z
2026-09-15 – 2026-09-1572026-10-21T10:28:28.8028566Z
2026-09-07 – 2026-09-0712026-10-21T10:28:28.8028566Z
2026-09-06 – 2026-09-0662026-10-21T10:28:28.8028566Z
2026-09-01 – 2026-09-0112026-10-21T10:28:28.8028566Z
2026-08-31 – 2026-08-3112026-10-21T10:28:28.8028566Z
2026-08-28 – 2026-08-2812026-10-21T10:28:28.8028566Z
2026-08-25 – 2026-08-2512026-10-21T10:28:28.8028566Z
2026-08-24 – 2026-08-2452026-10-21T10:28:28.8028566Z
2026-08-23 – 2026-08-2332026-10-21T10:28:28.8028566Z
2026-08-21 – 2026-08-2112026-10-21T10:28:28.8028566Z
2026-08-19 – 2026-08-1912026-10-21T10:28:28.8028566Z
2026-08-17 – 2026-08-1732026-10-21T10:28:28.8028566Z
2026-08-15 – 2026-08-1532026-10-21T10:28:28.8028566Z
2026-08-14 – 2026-08-1422026-10-21T10:28:28.8028566Z
2026-08-10 – 2026-08-1012026-10-21T10:28:28.8028566Z
2026-08-09 – 2026-08-0932026-10-21T10:28:28.8028566Z
2026-08-08 – 2026-08-0842026-10-21T10:28:28.8028566Z
2026-08-02 – 2026-08-0222026-10-21T10:28:28.8028566Z
2026-08-01 – 2026-08-0112026-10-21T10:28:28.8028566Z
2026-07-30 – 2026-07-3012026-10-21T10:28:28.8028566Z
2026-07-27 – 2026-07-2722026-10-21T10:28:28.8028566Z
2026-07-26 – 2026-07-2612026-10-21T10:28:28.8028566Z
2026-07-24 – 2026-07-2412026-10-21T10:28:28.8028566Z
2026-07-23 – 2026-07-2322026-10-21T10:28:28.8028566Z

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.3.012 Mar 20264

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
mikiships/agentreflect

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:52 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:282dbb2378aba0724991077e11dfc9dc7df6e8d83839f27eecd02509e95ed44c