agentleFS
joeywhelanjoeywhelan/judged-feedback/CLAUDE.md

judged-feedback

CLAUDE.md0 starsChanged 51 days agoMITView on GitHub

This is a Jupyter notebook demo (demo.ipynb) that builds a product-feedback analysis pipeline for a synthetic first-party retailer. The notebook is the published artifact; cell outputs from a recorded run are committed. API keys are captured into Python variables in Section 4 and never printed, never passed as shell arguments. The agent key is also written by PyYAML into the CLI config file (out/elasticrc.yml, the CLI's own credential store) as the agent context; the CLI has no stdin/env path for…

  • Reads credentials

The file

We split this CLAUDE.md into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Follow this sequence from assets/plan.md §11.5:

    line 84
  2. Very specific:

    Write-up: assets/article.md, image prompts, images

    line 93
  3. Very specific:

    Before writing any !elastic cell or the feedback-triage skill, read the installed Elastic Agent Skills (npx skills add …

    line 111

≈ “Common” is an estimate: at least 1 in 5 of the 28,029 CLAUDE.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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

# Install dependencies
uv sync

# Launch the notebook
uv run jupyter lab demo.ipynb

# Run the whole notebook non-interactively (there is no per-section run)
uv run jupyter nbconvert --to notebook --execute --inplace demo.ipynb

# Resize a generated image to its article preset (cover | arch | section, or WxH)
assets/images/resize.sh section ~/Downloads/generated.png assets/images/section1.png

# Verify CLI tools are present
elastic --version
claude --version

Architecture

This is a Jupyter notebook demo (demo.ipynb) that builds a product-feedback analysis pipeline for a synthetic first-party retailer. The notebook is the published artifact; cell outputs from a recorded run are committed.

Three principals with distinct scopes

PrincipalCredentialElasticsearch access
Human/adminCLI --save-as admin contextread + write all indices
Batch jobBATCH_KEY (in-memory only)read feedback-raw, products; write feedback-judgments
Agent (claude -p)AGENT_KEY (in-memory, and stored as the CLI agent context credential)read-only all indices; outputs files to out/ only

API keys are captured into Python variables in Section 4 and never printed, never passed as shell arguments. The agent key is also written by PyYAML into the CLI config file (out/elasticrc.yml, the CLI's own credential store) as the agent context; the CLI has no stdin/env path for it. The Elastic Cloud key (EC_API_KEY) gets the same treatment in Section 1: PyYAML writes the cloud context into that file (mode 0600) rather than elastic config context add --cloud-api-key. The batch key lives only in memory. agent is the current context from Section 4 on; admin cells always pass --use-context admin.

Data flow

synth.py → feedback-raw (append-only)
         → products (catalog)

judge.py + Jev API → feedback-judgments (one doc per feedback_id × rubric_version)

claude -p (agent context, read-only) → out/report.md + out/actions.ndjson

Human reads report → executes approved elastic commands from admin context

Key indices

  • feedback-raw: source-of-truth reviews and returns; never modified after ingest
  • feedback-judgments: one doc per (feedback_id, rubric_version); denormalized keys for ES|QL aggregation; Choice answers stored as {label, confidence} objects; probabilities map stored with enabled: false (in _source only, not indexed); severity.score arrives from Jev as a fractional 0–3 value (e.g. 0.85) although the mapping types it integer
  • products: catalog; proposable fields are fit_note, fit_guidance, known_issues, available only

Jev (TypeSafe AI) judge

judge.py calls POST https://api.typesafe.ai/v1/systemone with {"model": "jev-latest", "state": <item>, "questions": <rubric>}. Question types: choice, score, noul. Retry on 429/529/5xx with jittered exponential backoff via tenacity; 400/401 are not retried. Each answer in the response carries type; judge._flatten reads noul (float) for nouls, choice/confidence/probabilities for choices, and score (float)/confidence for scores. These names came from a live smoke test; re-check against a raw response if the API changes. Before the batch, judge.run_labeled gates the rubric against assets/data/labeled.json (≥ 27/30; the recorded run scored 27/30).

Agent constraints

The claude -p invocation in Section 7 passes explicit --allowedTools on the command line. The .claude/settings.json deny rules apply for interactive development in this repo:

{
  "permissions": {
    "deny": [
      "Bash(curl *)", "Bash(wget *)", "Bash(python*)", "Bash(uv *)", "Bash(jq *)",
      "Read(assets/rules/**)", "Edit(assets/rules/**)",
      "Read(.env)", "Read(~/.elasticrc.yml)", "Read(~/.config/**)"
    ]
  }
}

Rubric versioning

assets/rules/rubric_v1.json is the versioned Jev question set. Changing it bumps the version; judge.py selects items missing the current version so re-judging is incremental. The agent cannot read or write this file.

Build order

Follow this sequence from assets/plan.md §11.5:

  1. assets/rules/rubric_v1.json — smoke-test one review against Jev and print raw response
  2. src/judged_feedback/synth.py — write_fixtures() emits assets/data/{products,feedback}.ndjson, labeled.json, and the planted_signals.json sidecar; check the table via print_planted_signals()
  3. src/judged_feedback/judge.py — run on labeled set; tune rubric until ≥27/30 agreement
  4. Notebook Sections 1–4 against a live project; verify each !elastic cell with --help first
  5. Sections 5–6
  6. .claude/skills/feedback-triage/SKILL.md, assets/prompts/agent-task.md, .claude/settings.json — then Section 7 (expect 2–3 iterations)
  7. Sections 8–9 (human executes, teardown); run the whole notebook twice from a clean machine
  8. Write-up: assets/article.md, image prompts, images

Status: steps 1–7 are built and the notebook is committed with outputs from a recorded run (all five planted signals found, no finding on the shipping decoys, two approved commands executed). Open items: the two clean-machine runs, and the README's "left out for production" paragraph. The checklist is in assets/plan.md §9.

Write-up

  • assets/article.md is the published narrative for Sections 1–7 (Section 8 is one bullet). The notebook's markdown cells are titles only (## Section N — Title).
  • The article does not argue the agent's restrictions (that was the leashed-agent article); it covers Jev judging, Elasticsearch aggregation, and the agent's recommendations.
  • Image-generation prompts live in assets/prompts/ (prompt_cover.txt, prompt_arch.txt, prompt_section{1..7}.txt). Generated images go through assets/images/resize.sh, whose presets are cover 1920×1080, arch 1600×1000, and section 900×300.

Environment

.env holds only EC_API_KEY (Elastic Cloud) and TYPESAFE_API_KEY. The admin Elasticsearch credential is stored by the CLI after --save-as admin; Python never reads it. Python cells take the Elasticsearch endpoint from out/project.json (Section 1 output), never from the CLI config.

Reference

The leashed-agent repo (https://github.com/joeywhelan/leashed-agent) is the reference for notebook style, provisioning cells, and the claude -p invocation. Its ~/.elasticrc.yml edit/restore pattern is replaced here by a per-run out/elasticrc.yml selected with ELASTIC_CLI_CONFIG_FILE; ~/.elasticrc.yml is never read or changed. Reuse its patterns; do not reuse its scenario.

Before writing any !elastic cell or the feedback-triage skill, read the installed Elastic Agent Skills (npx skills add elastic/agent-skills) for command patterns and ES|QL guidance.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.