AGENTS.md TypeScript Next.js Frontend

YourNextStore: ECサイト AGENTS.md

Commerce Kit SDKの例、Biomeリントルール、エラーハンドリングパターン、モード別エージェントワークフローノートを含むAIネイティブECプラットフォーム。

AGENTS.md · 64 lines
# AGENTS.md

Your Next Store -- e-commerce app built with Next.js App Router + Commerce Kit SDK.

## Commands
```bash
bun dev           # Dev server (port 3000)
bun run build     # Production build
bun start         # Production server
bun run lint      # Biome lint (--write to auto-fix)
bun run format    # Biome format
bun test          # Run tests (bun:test)
tsgo --noEmit     # Type check
```

## Key Files & Directories
```
app/                  # Pages, layouts, actions (App Router)
components/ui/        # Shadcn UI components (50+)
lib/commerce.ts       # Commerce API client
lib/money.ts          # Currency formatting (formatMoney)
lib/utils.ts          # Utilities
```

## Project Patterns

- Use `safe-try` for error handling: `const [error, result] = await safe(...)`
- Format prices with `formatMoney` from `lib/money.ts`
- Use functional array methods (`map`, `filter`, `reduce`), not loops
- No `any` types; rely on type inference; minimal return type annotations
- **Always quote paths** with special characters in shell commands

## Biome Rules

Avoid: default exports, `any`, `for...of`, `forEach` for mutations, missing hook deps.
Prefer: named exports, `map`/`filter`/`reduce`, type inference, `as const`, template literals.

## Commerce Kit SDK

```tsx
const products = await commerce.productBrowse({ active: true, limit: 12, offset: 0 });
const product = await commerce.productGet({ idOrSlug: productId });
const cart = await commerce.cartUpsert({ cartId, variantId: "v-123", quantity: 1 });
```

## Error Handling
```tsx
const [error, result] = await safe(commerce.productGet({ idOrSlug: productId }));
if (error || !result) return <div>Product not found</div>;
```

## Validation Checklist

- [ ] `tsgo --noEmit` -- no type errors
- [ ] `bun run lint` -- no lint errors
- [ ] `bun run format` -- code formatted
- [ ] `bun test` -- tests pass
- [ ] `bun run build` -- build succeeds

## Agent Workflow Notes

- **Explore agent**: Start with `lib/commerce.ts`, `app/layout.tsx`, `app/page.tsx`
- **Plan agent**: Check existing code first. Map to routes, API, UI, actions.
- **Implementation agent**: Validate with commands above before and after changes.
Share on X

こちらもおすすめ

Frontend カテゴリの他のルール

もっとルールを探す

CLAUDE.md、.cursorrules、AGENTS.md、Image Prompts の全 157 ルールをチェック。