Skip to content

chore(docs): document new frontend patterns in AGENTS.md#4466

Open
ardaerzin wants to merge 2 commits into
mainfrom
fe-chore/update-agents-with-updated-patterns
Open

chore(docs): document new frontend patterns in AGENTS.md#4466
ardaerzin wants to merge 2 commits into
mainfrom
fe-chore/update-agents-with-updated-patterns

Conversation

@ardaerzin
Copy link
Copy Markdown
Contributor

@ardaerzin ardaerzin commented May 27, 2026

Summary

Follow-up to a Slack thread with @mmabrouk: adds three sections to AGENTS.md capturing patterns from recent frontend work — primarily #4425 (workflow Fern migration + playground vitest setup).

New sections in AGENTS.md

  • Frontend API: Use the Fern Client — all new FE API code goes through @agenta/sdk's getAgentaSdkClient, not raw axios. Pattern, anti-patterns, migration policy, and a list of existing Fern-using domains (@agenta/entities/{gatewayTool,secret,event,testset,workflow}).
  • Code Placement: Packages vs. Application Code — quick heuristic + hard rules, with a forward pointer to the existing agenta-package-practices skill for the full ruleset.
  • Package Unit Teststests/unit/ layout (not src/), minimal vitest.config.ts, required scripts, Fern-client mocking pattern, what to test / skip. References commit 1c0a900 (exclude in-src tests from package build).

The "Dev Environment Tips" section at the top now points at the three new sections so they're discoverable on first read.

Patterns sourced from PR #4425

  1. Using Fern when adding new API endpoints — commit c3572fd
  2. Heuristic for packages vs. main code — already in agenta-package-practices skill, summarized + linked
  3. Unit tests for packages — commit b59eddb
  4. Mocking Fern in unit tests — see tests/unit/retrieveWorkflowRevision.test.ts

Test plan

Documentation only — no functional changes.

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

Contributor Resources

Adds three sections capturing patterns from recent FE work, primarily
PR #4425 (workflow Fern migration + playground vitest setup):

- "Frontend API: Use the Fern Client" — all new FE API code goes
  through @agenta/sdk's getAgentaSdkClient, not raw axios. Pattern,
  anti-patterns, migration policy, references to existing Fern-using
  domains.

- "Code Placement: Packages vs. Application Code" — quick heuristic
  + hard rules, with a forward pointer to the existing
  agenta-package-practices skill for the full ruleset.

- "Package Unit Tests" — layout (tests/unit/, not src/), minimal
  vitest config, scripts, Fern-client mocking pattern, what to
  test / skip. References commit 1c0a900 (exclude in-src tests
  from package build).

Dev Environment Tips section now points to the three new sections
so they're discoverable from the top of the file.

Source: Slack thread between Mahmoud and Arda, 2026-05-27.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment May 27, 2026 6:23pm

Request Review

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. documentation Improvements or additions to documentation labels May 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Expanded contributor guidance for frontend development with clear API-integration best practices.
    • Added step-by-step advice for migrating legacy API calls and avoiding common anti-patterns.
    • Clarified package structure, code placement heuristics, unit-test layout, and testing priorities for frontend code.

Walkthrough

AGENTS.md is expanded with comprehensive contributor guidance for frontend development. The update introduces quick-start pointers to use the Fern client SDK, a detailed usage section with validation patterns and anti-examples, code placement conventions, package testing structure, and Vitest setup with mocking strategies.

Changes

Frontend Contributor Guidance

Layer / File(s) Summary
Quick-start guidance for frontend contributors
AGENTS.md
New introductory bullets recommend using the Fern-generated @agenta/sdk client instead of raw axios, and point contributors to package conventions and test location documentation.
Fern client usage patterns and validation
AGENTS.md
Detailed "Frontend API: Use the Fern Client" section covering required client setup (getAgentaSdkClient + getAgentaApiUrl), correct queryParams shape, Zod boundary validation via safeParseWithLogging, and explicit anti-pattern examples for axios and skipped validation.
Code organization and package test structure
AGENTS.md
Migration guidance for legacy axios calls, code placement decision heuristics between packages and application code, and package test directory layout rationale for @agenta/* packages.
Package unit tests and Node mocking
AGENTS.md
Required tests/unit/ layout, minimal vitest.config.ts template, and approach for mocking @agenta/ui in Node test environments.
Test scripts, Fern client mocking, and integration guidance
AGENTS.md
Standard package package.json test script template, concrete unit-test example mocking the Fern client (@agenta/sdk) including expected call/assertions, and guidance on integration test config and when to use integration vs unit tests.
What to test guidance
AGENTS.md
Lists high-value unit test targets (API request shape, boundary validation, pure derivation logic, guards) and explicitly what to skip (React tree dependencies, HTTP/transport-level behavior).

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore(docs): document new frontend patterns in AGENTS.md' directly and clearly describes the main change—adding frontend pattern documentation to AGENTS.md.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, detailing the three new sections added to AGENTS.md, their content, sources, and rationale.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fe-chore/update-agents-with-updated-patterns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
AGENTS.md (2)

1554-1565: 💤 Low value

Specify language for fenced code block.

The fenced code block should specify a language identifier for proper rendering. Use text for plain-text diagrams.

📝 Proposed fix
-```
+```text
 Is the code used by 2+ features, or could be?

1584-1593: 💤 Low value

Specify language for fenced code block.

The directory tree structure should specify a language identifier for proper rendering. Use text for plain-text diagrams.

📝 Proposed fix
-```
+```text
 web/packages/<pkg>/

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 80dba1b6-1e0c-4951-8f37-6c07bf609825

📥 Commits

Reviewing files that changed from the base of the PR and between fec4391 and bd55d80.

📒 Files selected for processing (1)
  • AGENTS.md

Copy link
Copy Markdown
Member

@mmabrouk mmabrouk left a comment

Choose a reason for hiding this comment

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

Thanks @ardaerzin !

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 27, 2026
Four refinements to the new sections, all surfaced by /plan-eng-review:

1. Frontend API: Use the Fern Client
   - Add a Prerequisite subsection: new packages adopting Fern must
     declare @agenta/sdk in package.json dependencies. Without it,
     tsc --noEmit fails on the import before runtime.
   - Migration policy: replace the single paragraph with three explicit
     bullets so the edge case "new function in existing axios-using
     file" is covered (use Fern; don't migrate sibling functions).

2. Package Unit Tests
   - Mocking the Fern client: add a one-paragraph note about singleton
     behaviour. The mock returns a fresh object per call; tests that
     depend on the production singleton need a stricter mock.
   - New "Integration tests" subsection covering vitest.integration
     .config.ts: separate config, raised timeouts, sequential
     execution, when to choose integration over unit. References
     @agenta/entities's existing integration test infra (4 files,
     setup/global.ts + setup/worker.ts).

No structural changes, no anchor changes, no removed content.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
AGENTS.md (1)

486-489: 💤 Low value

Minor wording clarification: "before the code runs" → "at type-check time".

The phrase "before the code runs" is slightly ambiguous. Consider "at type-check time" since tsc --noEmit is a compile-time check, not a runtime check.

📝 Suggested clarification
-The consuming package must declare `"`@agenta/sdk`": "workspace:../agenta-sdk"` in its `package.json` `dependencies`. Today `@agenta/entities` is the main consumer; any new package adopting Fern must add this dep first, otherwise `tsc --noEmit` fails on the `@agenta/sdk` import before the code runs.
+The consuming package must declare `"`@agenta/sdk`": "workspace:../agenta-sdk"` in its `package.json` `dependencies`. Today `@agenta/entities` is the main consumer; any new package adopting Fern must add this dep first, otherwise `tsc --noEmit` fails on the `@agenta/sdk` import at type-check time.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b97b655-c29b-41f0-a7fa-bfd77bec2630

📥 Commits

Reviewing files that changed from the base of the PR and between bd55d80 and a3e061c.

📒 Files selected for processing (1)
  • AGENTS.md

Comment thread AGENTS.md

Layout:

```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add language marker to fenced code block.

The directory tree structure should specify a language for the fenced code block to satisfy markdownlint.

📝 Proposed fix
-```
+```text
 web/packages/<pkg>/
 ├── vitest.integration.config.ts          # separate from vitest.config.ts
 └── tests/
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 1715-1715: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants