frontend-component-design

frontend-component-design is a skill for Claude Code, Codex from congwa/mobile-agent. It costs 95 tokens per session (997 once invoked), scanned A, original, Apache-2.0.

Frontend design guidelines for building React or Next.js components and pages. They explain how to split code, reuse components, organize folders, and keep configuration separate.

In plain words
What is it for?
Use them when creating, changing, or refactoring frontend components, pages, hooks, forms, themes, or shared configuration.
Why use it?
They reduce duplicated, oversized, and hard-to-maintain frontend code by giving developers consistent design rules.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/congwa/mobile-agent/frontend-component-design
Any agent
npx skills add congwa/mobile-agent --skill frontend-component-design
Clone the repo
git clone --depth 1 https://github.com/congwa/mobile-agent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for frontend-component-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/congwa/mobile-agent/frontend-component-design.svg)](https://agentmods.dev/skills/congwa/mobile-agent/frontend-component-design)
Your own site
<a href="https://agentmods.dev/skills/congwa/mobile-agent/frontend-component-design"><img src="https://agentmods.dev/badge/skills/congwa/mobile-agent/frontend-component-design.svg" alt="Measured on agentmods" height="20"></a>
Per session 95 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 997 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00095 $0.00997
Opus 5 $0.00048 $0.00498
Sonnet 5 $0.00019 $0.00199
Haiku 4.5 $0.00010 $0.00100

Measured 4d ago against content hash 9bc63b7f066f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

frontend-component-design scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.windsurf/skills/frontend-component-design/SKILL.md · 121 lines

How it starts

The opening of the file, as written. The whole thing — 121 lines — stays where its author put it; the contents beside it link to each section on GitHub.

前端组件设计规范

确保前端代码的复用性、封装性和可维护性。

核心原则

1. 单一职责原则

  • 每个文件只包含一个组件
  • 每个组件只负责一个业务功能
  • 组件代码不超过 500 行,超过则拆分

2. 组件拆分规则

# 拆分时机判断
if 组件 > 500 行:
    拆分为子组件
if 相同代码出现 >= 2 次:
    抽取为公共组件
if 业务逻辑复杂:
    抽取为 hooks
if 配置数据多:
    抽取为配置文件

3. 目录结构规范

frontend/
├── components/           # 公共组件
│   ├── ui/              # shadcn 基础组件
│   └── admin/           # 业务公共组件
├── app/                 # 页面
│   └── admin/
│       └── [feature]/
│           ├── page.tsx         # 主页面(协调逻辑)
│           └── components/      # 页面私有组件(可选)
├── lib/
│   ├── api/             # API 请求函数
│   ├── config/          # 配置和映射
│   └── hooks/           # 公共 hooks
├── hooks/               # 全局 hooks
└── types/               # 类型定义

4. 配置外置原则

将以下内容抽取到 lib/config/ 目录:

  • 标签映射labels.ts (英文→中文)
  • 枚举常量constants.ts
  • 表单配置forms.ts
  • 主题配置theme.ts

示例:

// lib/config/labels.ts
export const MIDDLEWARE_LABELS = {
  MemoryOrchestration: { label: "记忆编排", desc: "..." },
  // ...
};
export function getMiddlewareLabel(name: string) {
  return MIDDLEWARE_LABELS[name] || { label: name, desc: "" };
}

5. Hooks 抽取规则

抽取为 hook 的时机:

  • 状态逻辑复杂(>5 个 useState)
  • 数据获取逻辑
  • 副作用逻辑复杂
  • 相同逻辑在多处使用

命名规范:use[业务名][动作]

// lib/hooks/use-agents.ts
export function useAgentDetail({ agentId }: { agentId: string }) {
  const [agent, setAgent] = useState<Agent | null>(null);
  // ...
  return { agent, isLoading, error, refresh };
}

6. 导入路径规范

始终使用 @/ 别名,避免相对路径:

// ✅ 正确
import { Button } from "@/components/ui/button";
import { getAgentEffectiveConfig } from "@/lib/api/agents";

// ❌ 错误
import { Button } from "../../components/ui/button";

编码前规划清单

编写前端代码前,必须回答:

  1. 组件边界:这个组件的职责是什么?是否单一?
  2. 复用性:是否有已存在的类似组件可复用?
  3. 配置外置:是否有硬编码的中文/配置需要抽取?
  4. 文件大小:预估代码行数,是否需要拆分?
  5. 命名规范:组件/文件命名是否清晰表达业务含义?

代码审查要点

完成编码后,检查:

  • 单文件不超过 500 行
  • 无重复代码(相同代码不超过 2 处)
  • 所有中文标签来自配置文件
  • 使用 @/ 路径别名
  • 组件职责单一
  • 复杂逻辑已抽取为 hooks

Read the full file on GitHub · 121 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 121 lines · 95 tokens per session scan A 9bc63b7f066f

Subscribe to this mod's changes

frontend-component-design is a skill published in the GitHub repository congwa/mobile-agent (44 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 95 tokens to every session and 997 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories