在 Cursor 中打造你的专属前端“AI 助手”:Agent Skills 实战指南 什么是 Agent Skills?p p h4 id E6 96 87 E7 AB A0 E7 9B AE E5 BD 95 文章目录 h4 ul li 一 什么是 Agent Skills li li 二 使用步骤 ul li 1 li ul li ul
--- name: react-component-gen description: Generate a new React functional component with CSS Modules and TypeScript interfaces following team standards. disable-model-invocation: false --- # React Component Generator Use this skill when the user asks to create a new UI component, page, or widget. [...](asc_slot://start-slot-9)Instructions 1. Analyze the Request: Identify the component name and props required. 2. Directory Structure: - Create a folder named exactly as the component (PascalCase). - Inside, create `index.tsx` and `styles.module.scss`. 3. Code Standards: - index.tsx: - Use `FC` type from 'react'. - Import styles as `import styles from './styles.module.scss'`. - Define an interface `[ComponentName]Props`. - Export the component as default. - styles.module.scss: - Create a root class `.container`. - Use BEM naming convention for inner elements if needed. [...](asc_slot://start-slot-11)Template Example If the user asks for a "Button", generate: tsx // Button/index.tsx import React, { FC } from 'react'; import styles from './styles.module.scss'; export interface ButtonProps { label: string; onClick: () => void; } const Button: FC
= ({ label, onClick }) => { return (
); }; export default Button;
SKILL.md: markdown --- name: refactor-color description: Refactor hardcoded hex colors to Tailwind utility classes. --- # Color Refactoring [...](asc_slot://start-slot-17)Instructions 1. Run the script `scripts/find-hex.js` to locate hex codes in the current file. 2. For each hex code found, map it to the closest Tailwind color (e.g., `#ef4444` -> `text-red-500`). 3. Rewrite the code.
这样,AI 就不只是在“瞎猜”,而是真正执行了你写的工具脚本来辅助它工作。
团队规范统一:把这个 .cursor 文件夹提交到 Git 仓库,新入职的同事 git pull 下来,他的 AI 助手立刻学会了全套团队规范,不用手把手教。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/256498.html