Skip to content

docs: add review-facing CLAUDE.md guidance (draft for team review) - #2916

Open
piyalbasu wants to merge 6 commits into
masterfrom
docs/claude-md-review-guidelines
Open

docs: add review-facing CLAUDE.md guidance (draft for team review)#2916
piyalbasu wants to merge 6 commits into
masterfrom
docs/claude-md-review-guidelines

Conversation

@piyalbasu

@piyalbasu piyalbasu commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Our automated PR reviewer (/code-review) reads CLAUDE.md and checks each change against it, and non-Claude tools read AGENTS.md — but the review-relevant rules were thin/split. This consolidates a set of specific, review-checkable invariants (led by the wallet's secret-handling rule) into AGENTS.md, and symlinks CLAUDE.md → AGENTS.md so every review path reads the same source with no drift.

Draft on purpose: please ratify the rules before this lands — a wrong or over-broad rule makes reviewers (and coding agents) confidently wrong. Poke holes.

Details (for reviewers)

Why here: /code-review gathers CLAUDE.md (root + modified dirs) and audits diffs against it; other agent tools read AGENTS.md; Claude Code sessions auto-load both. The repo already had a rich AGENTS.md plus a near-empty extension/CLAUDE.md, so review rules had no real home and would fragment if added Claude-only. One file, both names, avoids that.

What changed:

  • AGENTS.md — new "Invariants — must always hold" section (after Security-Sensitive Areas):
  • CLAUDE.mdAGENTS.md symlink (root).
  • extension/e2e-tests/AGENTS.md (new) — backend-v2 requests run in the MV3 service worker → mock with context.route/context.on, not page.route/page.on; extension/e2e-tests/CLAUDE.mdAGENTS.md symlink.

Design constraints: every rule names the real helper/artifact so it's citable against a line; nothing a linter/typechecker/CI already enforces is included (the reviewer skips those by design).

Known caveats:

  • @stellar/* pinning reflects a stated team convention; I did not verify current package.json pins them — confirm.
  • The "not resident in memory past lock" clause is hard for a diff-scoped reviewer to verify; the observable channels (logging, request/JWT payload, popup boundary) are what it will actually catch.
  • The pre-existing extension/CLAUDE.md (a specs pointer) is left as-is; symlinking it to an extension/AGENTS.md is a possible follow-up if you want that dir's guidance to reach non-Claude tools too.

Provenance: came out of a benchmarking effort on whether a pre-PR review skill could beat /code-review — it couldn't add much autonomously, but the investigation showed that feeding the reviewer good AGENTS.md/CLAUDE.md context is the higher-leverage move. This PR is that follow-through.

/code-review ingests CLAUDE.md and audits diffs against it, but this repo only
had a 7-line extension/CLAUDE.md pointing at specs/ — so the review's
compliance agents had nothing to check. Add specific, citable rules:

- root CLAUDE.md: lead secret-leak invariant (decomposed into concrete leak
  channels + anchored to the background/popup boundary), backend-v2 chokepoint
  usage, cache/side-effect-ordering rules (from real regressions #2603/#2605),
  @stellar/* exact-version pinning, and a TODO(team) domain-invariants section.
- extension/e2e-tests/CLAUDE.md: backend-v2 calls run in the MV3 service worker;
  mock with context.route/context.on, not page.route/page.on.

Rules are written to be citable against a line and exclude anything CI already
enforces. Domain invariants are stubbed for the team to fill — these need
ratification before merge; opening as a draft.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-b96c5d743ddf9f0bc2bd (SDF collaborators only — install instructions in the release description)

piyalbasu and others added 5 commits July 23, 2026 13:51
Every transaction sign/submit flow (dApp sign, send, swap, send-collectible)
must attempt a Blockaid scanTx (via useScanTx) and surface the scanResult before
signing; on unable-to-scan, show the explicit warning rather than silently
proceeding. Grounded in the existing scanTx/useScanTx pattern.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Network-dependent code must handle Mainnet/Testnet/Futurenet AND custom
networks (isCustomNetwork); a NETWORKS switch needs a default/custom branch;
unsupported networks get an explicit graceful fallback, not an unhandled case.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Any code touching addresses must handle classic G accounts, contract C
addresses (isContractId), muxed M accounts (isMuxedAccount), and federated
addresses (isFederationAddress/isValidFederatedDomain): resolve federated before
use, preserve the muxed memo id, route C addresses where an account is expected,
validate with isValidStellarAddress. Completes the domain-invariants section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
All four seed invariants filled (decimals, network, signing/Blockaid,
addresses); drop the "TODO(team)" from the header now that it's a live list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The repo already had a rich AGENTS.md (the file non-Claude tools read) while my
new CLAUDE.md was Claude-only — fragmenting guidance. Consolidate to one source
of truth:

- Fold the review invariants (secret-leak, backend-v2 chokepoint, cache/ordering,
  @stellar pinning, and the four domain invariants) into AGENTS.md as an
  "Invariants — must always hold" section, next to Security-Sensitive Areas.
- Replace the standalone root CLAUDE.md with a symlink -> AGENTS.md, and do the
  same for the e2e-tests dir (new extension/e2e-tests/AGENTS.md + symlinked
  CLAUDE.md).

Now every path reads the same content: /code-review (via CLAUDE.md), Codex/other
tools (via AGENTS.md), and Claude Code sessions (which auto-load it) — no drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@piyalbasu
piyalbasu marked this pull request as ready for review July 23, 2026 22:40
Copilot AI review requested due to automatic review settings July 23, 2026 22:40

Copilot AI 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.

Pull request overview

Consolidates Freighter’s automated-review guidance and shares it across agent tools via symlinks.

Changes:

  • Adds security, backend, caching, dependency, and domain invariants.
  • Documents service-worker request interception for E2E tests.
  • Links Claude guidance to the corresponding agent documents.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
AGENTS.md Adds review-facing invariants.
CLAUDE.md Links to root agent guidance.
extension/e2e-tests/AGENTS.md Documents backend-v2 E2E interception.
extension/e2e-tests/CLAUDE.md Links to E2E agent guidance.
Comments suppressed due to low confidence (1)

AGENTS.md:145

  • Dedicated popup flows currently return mnemonicPhrase from the background after password validation (getMnemonicPhrase.ts:49-51 and showBackupPhrase.ts:64-66). Saying only { status, body } crosses this boundary is therefore false. Restrict that response shape to backend-v2 derivation and explicitly carve out authenticated mnemonic-display/onboarding flows while retaining the private/auth-key prohibition.
- returned across the background→popup boundary — key derivation happens in the
  background service worker; only `{ status, body }` (never the mnemonic/key)
  crosses back to the popup;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md
Comment on lines +139 to +140
- written to disk or unencrypted storage — they live only in the encrypted
session store;
Comment thread AGENTS.md
Comment on lines +192 to +198
- **Address handling:** any code that accepts, parses, displays, resolves, or
routes a Stellar address must handle all four types — classic **G** accounts,
contract **C** addresses (`isContractId`), muxed **M** accounts
(`isMuxedAccount`), and **federated** addresses (`isFederationAddress` /
`isValidFederatedDomain`). Resolve federated before use; preserve/extract the
muxed memo id (don't strip or mislabel it); route C addresses appropriately
where a fundable account is expected; validate with `isValidStellarAddress`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants