Skip to content

docs: improve AI agent instructions and dev workflow guidance [skip ci] (#8284) [skip ci] - #8284

Merged
rfay merged 6 commits into
ddev:mainfrom
rfay:20260403_rfay_claude_md
Apr 7, 2026
Merged

docs: improve AI agent instructions and dev workflow guidance [skip ci] (#8284) [skip ci]#8284
rfay merged 6 commits into
ddev:mainfrom
rfay:20260403_rfay_claude_md

Conversation

@rfay

@rfay rfay commented Apr 3, 2026

Copy link
Copy Markdown
Member

The Issue

AI agent instructions in CLAUDE.md and AGENTS.md had gaps: no allow permissions for common safe operations, no guidance on using upstream/main for PR comparisons, and the make staticrequired hook behavior wasn't clearly documented.

How This PR Solves The Issue

.claude/settings.json — add allow permissions:

  • curl to github.com, raw.githubusercontent.com, buildkite.com
  • Read-only gh subcommands: issue/pr/run list, view, checks, diff, status
  • make*, go test*, gofmt*, ls*

These are safe, frequently used operations that shouldn't require manual approval on every invocation.

CLAUDE.md and AGENTS.md — upstream/main comparison guidance:

When generating diffs for a PR, prefer upstream/main as the base if the remote exists, fall back to origin/main. Local main may be stale. Not all developers use an upstream remote, so the guidance handles both cases gracefully.

CLAUDE.md — clarify make staticrequired hook behavior:

Made explicit that a PreToolUse hook in .claude/settings.json runs make staticrequired automatically before every git commit, and that gofmt/markdownlint --fix run via PostToolUse hooks after edits.

Note on CLAUDE.md vs AGENTS.md:

Claude Code now reads both CLAUDE.md and AGENTS.md. We are not consolidating them at this time because AGENTS.md serves other AI tools (Codex, Gemini, etc.) and the two files have meaningfully different audiences. Consolidation would be worth revisiting if the content continues to diverge in maintenance cost.

Manual Testing Instructions

  1. Open repo in Claude Code
  2. Verify make, go test, ls, and gh pr list no longer prompt for approval
  3. Verify curl https://api.github.com/... no longer prompts for approval
  4. Check that git commit still triggers make staticrequired via the hook

Automated Testing Overview

Documentation and config only — no code changes. Markdown linting passes.

Release/Deployment Notes

No impact on DDEV functionality.

rfay and others added 2 commits April 3, 2026 13:20
- Add allow permissions to .claude/settings.json for curl (github.com,
  raw.githubusercontent.com, buildkite.com), read-only gh subcommands
  (issue/pr/run list/view/checks/diff/status), make, go test, gofmt, ls
- Add upstream/main comparison guidance to CLAUDE.md and AGENTS.md:
  prefer upstream/main if remote exists, fall back to origin/main

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Make explicit that the PreToolUse hook runs `make staticrequired`
automatically before every `git commit`, and that gofmt/markdownlint
run via PostToolUse hooks after edits.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rfay
rfay requested a review from a team as a code owner April 3, 2026 19:24
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rfay
rfay requested a review from stasadev April 3, 2026 19:29
rfay and others added 3 commits April 5, 2026 08:39
Allow common read-only commands: cat, head, tail, wc, sort, uniq, cut,
tr, diff, find, which, type, echo, printf, jq, awk, grep, sed, git
read subcommands (log/diff/status/show/blame/branch/remote),
golangci-lint, markdownlint.

Deny destructive variants: sed -i, find -delete, find -exec rm.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ddev.site URLs resolve locally but use external domain names, so the
localhost deny rules were unnecessary friction. WebFetch(domain:*) is
sufficient.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@jonesrussell jonesrussell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Claude Code

Reviewed the three changed files (.claude/settings.json, CLAUDE.md, AGENTS.md). The documentation improvements are solid — notably correcting the inaccurate "PreToolUse and PostToolUse" description to correctly say PostToolUse for gofmt/markdownlint. The PreToolUse hook description for make staticrequired is verified accurate against the actual settings.json config.

A few things worth considering:


curl allow patterns match arbitrary domains

The patterns like Bash(curl*github.com*) will match any curl invocation where github.com appears anywhere in the argument string — including as a query parameter or path fragment on a different host (e.g., curl https://evil.com/?ref=github.com).

Consider anchoring to the scheme + domain:

"Bash(curl https://github.com*)"
"Bash(curl https://raw.githubusercontent.com*)"
"Bash(curl https://buildkite.com*)"

git fetch upstream 2>/dev/null silently swallows real errors

In both CLAUDE.md and AGENTS.md, the pattern:

git fetch upstream 2>/dev/null || git fetch origin

If upstream exists but fetch fails for a real reason (expired SSH key, network timeout), stderr is suppressed and the fallback silently fetches origin instead. The agent then diffs against a potentially wrong base with no warning.

Separating remote detection from fetching would be more robust:

if git remote get-url upstream >/dev/null 2>&1; then
  git fetch upstream
else
  git fetch origin
fi

Minor pattern concerns in the allow/deny lists

  • Bash(tr*) — matches truncate as well as tr. Could silently allow truncate -s 0 <file>.
  • Bash(git branch*) — matches git branch -D (force delete). If the intent is read-only listing, consider denying Bash(git branch -D*) and Bash(git branch -d*).
  • Bash(find*-exec rm*) deny — doesn't catch find -exec /usr/bin/rm or find -exec unlink. Consider broadening to Bash(find*-exec*) if the goal is blocking destructive find operations.

Duplicated section across CLAUDE.md and AGENTS.md

The "Comparing Against Upstream" section is word-for-word identical in both files. The PR body explains why both files exist (different audiences), which makes sense. A small <!-- Keep in sync with AGENTS.md --> comment in each might help prevent drift over time.


Overall this is a useful improvement to the AI agent workflow. The documentation accuracy fixes are a clear win. The permission patterns are a good idea — the suggestions above are about tightening the globs rather than questioning the approach.

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@rfay

rfay commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

Think these are probably "good enough" for now.

@rfay rfay changed the title docs: improve AI agent instructions and dev workflow guidance [skip ci] docs: improve AI agent instructions and dev workflow guidance [skip ci] (#8284) [skip ci] Apr 7, 2026
@rfay
rfay merged commit 11f5926 into ddev:main Apr 7, 2026
4 checks passed
@rfay
rfay deleted the 20260403_rfay_claude_md branch April 7, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants