claude-repo-native-agent-lab

Claude Repo-Native Agent Lab

One primary Claude agent + repo-local instructions + discoverable skills + deterministic Python tools, producing a Repository Readiness Report you can run on a laptop.

Claude Repo-Native Agent Runtime: single agent + skills + optional subagents

Scaffolded from intent-drive-starter (Intent-Driven Engineering): the full original brief is intent/INTENT-001-original.md, its condensed working form is intent/current-feature.md, and changes are appended as deltas using templates/delta-template.md.

Everything lives in the repository. The Claude runtime (Claude Code via the Claude Agent SDK) executes on your machine; it is not source code in this repo. No Lambda, service, database or CI in this iteration.

Quick start

cd claude-repo-native-agent-lab
python -m venv .venv && source .venv/bin/activate      # Python 3.11+
python -m pip install -e '.[dev]'

python agent.py test                                   # 1. local tests, no credentials
python agent.py scan --target samples/demo_project     # 2. deterministic, offline, no AI
python agent.py agent --target samples/demo_project    # 3. real Claude session (needs credentials)

1. test

Runs pytest (42 tests): scanner checks, evidence schema, determinism, redaction, the agent tool guard, and CLI success/failure paths. Never calls Claude.

2. scan — deterministic, offline, not an AI agent

Writes output/evidence.json and output/report.md. Exit code 0 means the scan completed, even when checks fail; 2 means a bad target. Expected on the shipped sample:

Readiness scan (deterministic, no AI): samples/demo_project
  [PASS] readme_present
  [WARN] tests_present
  [FAIL] python_compiles
  [PASS] no_env_file
  [PASS] dependency_manifest
  [WARN] hardcoded_secrets
Summary: 3 pass, 2 warn, 1 fail

Fix the sample (steps in samples/demo_project/README.md) and re-run to see it change.

3. agent — a real Claude Agent SDK session

Prerequisites: Python 3.11+, claude-agent-sdk (installed above; it bundles the Claude Code runtime), and Claude credentials on your machine: claude login, or ANTHROPIC_API_KEY exported in your shell. Never paste keys into chat or commit them.

What happens:

  1. agent.py checks prerequisites and fails with the exact missing item if any are absent (exit 3).
  2. It starts a ClaudeSDKClient with cwd = repo root, setting_sources=["project"] (loads CLAUDE.md, .claude/settings.json, .claude/skills), tools limited to Read/Glob/Grep/Bash/Skill, max_turns=20, max_budget_usd=1.00 (override with --max-turns, --max-budget-usd, --model).
  3. Claude invokes the implementation skill (runs the scan, reads the evidence), then the validation skill (runs tests, checks schema/report agreement, greps for unmasked secrets), then answers with an assessment and prioritized fixes.
  4. Every tool call passes through tools/guard.py as a PreToolUse hook — plain Python that allows only reads inside the repo, the two agent.py commands, and the two project skills. Everything else is denied.
  5. Outputs: output/agent-summary.md (Claude’s interpretation, labelled as such) and output/agent-run.json (skills discovered and invoked, every tool call, guard denials, turns, cost, and whether evidence was regenerated during the session). On failure only agent-run.json is written and the exit code is 4. An offline scan is never substituted for an agent run.

Output locations

File Producer Contains
output/evidence.json tools/readiness.py (deterministic) schema 1.0: target, checks, summary, redaction_applied
output/report.md tools/readiness.py (deterministic) table of checks, next actions, evidence SHA-256
output/agent-summary.md Claude (agent mode) assessment + prioritized fixes
output/agent-run.json agent.py (agent mode) session trace used as evidence of what the agent actually did

Everything in output/ except .gitkeep is git-ignored.

Architecture

For the workflow this repo demonstrates, and how to apply it to new plugin skills, hooks and agents, open docs/plugin-development-guide.html in a browser.

User intent ─► agent.py agent ─► Claude Agent SDK ─► Claude Code runtime (local) ── active loop
                                     │                    │ plan → load skill → call tool → validate
                                     │                    ▼
            CLAUDE.md, intent/ ──────┤        PreToolUse hook: tools/guard.py (deterministic allow/deny)
            .claude/skills/* ────────┤                    ▼
            .claude/agents/* (inactive)        Bash: python agent.py scan|test ─► tools/readiness.py
            .claude/settings.json ───┘                                         └► tools/redact.py
                                                                    ▼
                                                     output/evidence.json + report.md (+ agent trace)
Piece Role
CLAUDE.md project rules: minimum autonomy, repo-only, no network, evidence over assertion, stop conditions
.claude/skills/implementation procedure: run scan → read evidence → prioritized fixes
.claude/skills/validation procedure: tests → schema → report cross-check → secret grep → PASS/FAIL
.claude/agents/reviewer.md, researcher.md definitions only. In interactive Claude Code a subagent starts only if you explicitly ask. In agent mode (agent.py) the guard blocks subagents entirely, even if asked
.claude/settings.json allows the two agent.py commands, denies .env reads, web tools, curl, wget, rm, git push
tools/readiness.py 6 checks; compiles Python with compile() but never executes it; bounded, symlink-safe walk
tools/redact.py masks API-key/password/token assignments, Bearer tokens, sk-/ghp_/AKIA/xox shapes
tools/guard.py the enforced tool policy for agent mode

Policy that matters is enforced in Python (redaction, file and command boundaries), not by a skill or prompt.

What the guard is and isn’t. It controls which Claude tools may run and with what inputs, before each call. It is not an operating-system sandbox: the approved commands run as your user with your file permissions, and nothing here isolates the process. For untrusted code, run the demo in a container or VM. The guard also blocks a search (Grep) whenever a real .env file could be in its results.

Using the skills interactively in Claude Code

Open Claude Code in this directory (claude), accept the workspace trust prompt, then either type /implementation or /validation, or ask “run a readiness report on samples/demo_project”. Both skills appear in the skill list because they follow the documented layout .claude/skills/<name>/SKILL.md with name and description frontmatter. Claude Code will ask permission for anything outside the permissions.allow list.

Troubleshooting

Symptom Cause / fix
Claude Agent SDK for Python is not installed (exit 3) python -m pip install -e '.[dev]'
Authentication error / apiKeySource: "none" (exit 4) run claude login or export ANTHROPIC_API_KEY, then retry
Ignoring 4 permissions.allow entries ... workspace has not been trusted harmless in agent mode (the guard hook makes allow/deny decisions). For interactive use, open claude here once and accept trust
error_max_turns / error_max_budget_usd raise --max-turns / --max-budget-usd deliberately
python: command not found use python3 agent.py ...; the guard accepts both
Skill list in agent-run.json includes non-project skills the runtime also lists built-in skills; the guard still only lets implementation and validation run

Next step: GitHub Actions (later)

Add a workflow that runs python agent.py test and python agent.py scan on every push and uploads output/ as an artifact. Agent mode in CI comes after that, with the API key in GitHub Secrets.