ARTICLE DETAIL

资讯详情

深耕网站视觉设计与运营推广的一线实战洞察。

When to Activate

When to Activate When to Activate【免费下载链接】ECCThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.项目地址: https://gitcode.com/GitHub_Trending/ev/ECCCreating new React componentsRefactoring existing componentsDebugging React state issuesReviewing React code for best practices### 5.2 Show, Dont Tell——用代码说话 **失败示例**只有口号没有操作价值 markdown ## Error Handling Always handle errors properly in async functions.成功示例先给完整代码再提炼关键点async function fetchData(url: string) { try { const response await fetch(url) if (!response.ok) { throw new Error(HTTP ${response.status}: ${response.statusText}) } return await response.json() } catch (error) { console.error(Fetch failed:, error) throw new Error(Failed to fetch data) } }Key PointsCheckresponse.okbefore parsingLog errors for debuggingRe-throw with user-friendly message5.3 必须包含反模式Anti-Patterns什么不该做和该怎么做同样有价值## Anti-Patterns ### FAIL: Direct State Mutation typescript // NEVER do this user.name New Name items.push(newItem)PASS: Immutable Updates// ALWAYS do this const updatedUser { ...user, name: New Name } const updatedItems [...items, newItem]### 5.4 提供可勾选的检查清单Checklists 清单具有可执行、易跟进的特质 markdown ## Pre-Deployment Checklist - [ ] All tests passing - [ ] No console.log in production code - [ ] Environment variables documented - [ ] Secrets not hardcoded - [ ] Error handling complete - [ ] Input validation in place5.5 用决策树处理复杂取舍Decision Trees当多种方案各有适用场景时用树形文本比大段叙述更高效Need to fetch data? ├── Single request → use fetch directly ├── Multiple independent → Promise.all() ├── Multiple dependent → await sequentially └── With caching → use SWR or React Query六、Best Practices做与不做的行为准则6.1 DO——应该做的实践示例要具体UseuseCallbackfor event handlers passed to child components给示例包含可复制粘贴的代码解释 WHYImmutability prevents unexpected side effects in React state关联相关技能See also:react-performance保持聚焦一个技能 一个领域/概念善用小节清晰标题便于快速扫读6.2 DONT——不要做的实践为什么糟糕空泛Write good code——不可执行长篇大论难以解析不如写成代码覆盖过广Python, Django, and Flask patterns——过于宽泛跳过示例没有实践的理论价值大打折扣忽略反模式学会不该怎么做同样重要6.3 内容体量指南长度通常 200–500 行上限 800 行代码块必须带语言标识符标题层级使用##与###层级结构列表无序用-有序用1.表格用于对比与速查。七、三种高频技能模板Common Patterns技能写作存在三类被反复验证的骨架遇到同类主题可直接套用。模式 1标准类技能Standards Skill--- name: language-standards description: Coding standards and best practices for [language]. --- # [Language] Coding Standards ## When to Activate - Writing [language] code - Code review - Setting up linting ## Naming Conventions | Element | Convention | Example | |---------|------------|---------| | Variables | camelCase | userName | | Constants | SCREAMING_SNAKE | MAX_RETRY | | Functions | camelCase | fetchUser | | Classes | PascalCase | UserService | ## Code Examples [Include practical examples] ## Linting Setup [Include configuration] ## Related Skills - language-testing - language-security仓库中的 skills/coding-standards/SKILL.md 是该模式的高级演化实例它在正文开头即声明这是所有项目的共享地基不是框架级剧本并明确 Scope Boundaries哪些场景激活、哪些场景应改用frontend-patterns、backend-patterns等更窄技能把技能边界管理做成了可执行规范。模式 2工作流类技能Workflow Skill--- name: task-workflow description: Step-by-step workflow for [task]. --- # [Task] Workflow ## When to Activate - [Trigger 1] - [Trigger 2] ## Prerequisites - [Requirement 1] - [Requirement 2] ## Steps ### Step 1: [Name] [Description] bash [Commands] ### Step 2: [Name] [Description] ## Verification - [ ] [Check 1] - [ ] [Check 2] ## Troubleshooting | Problem | Solution | |---------|----------| | [Issue] | [Fix] |仓库中 skills/tdd-workflow/SKILL.md 将这一模式发挥到极致它额外引入了 Plan Handoff把*.plan.md当作不可信的数据输入而非指令先消毒再执行、80% 覆盖率门槛、RED/GREEN 证据映射与安全检查清单展示了一个生产级工作流技能应有的严谨度。模式 3速查参考类技能Reference Skill--- name: api-reference description: Quick reference for [API/Library]. --- # [API/Library] Reference ## When to Activate - Using [API/Library] - Looking up [API/Library] syntax ## Common Operations ### Operation 1 typescript // Basic usage ### Operation 2 typescript // Advanced usage ## Configuration [Include config examples] ## Error Handling [Include error patterns]八、测试你的技能8.1 本地测试三步法第 1 步拷贝到 Claude Code 技能目录cp -r skills/your-skill-name ~/.claude/skills/第 2 步用触发场景实测You: I need to [task that should trigger your skill] Claude should reference your skills patterns.第 3 步验证激活效果请 Claude 解释你技能中的某个概念检查它是否复用了你的示例与模式确认它遵守了你的准则。8.2 上线前的验证清单YAML Frontmatter 合法——无语法错误命名符合约定——小写加连字符描述足够清晰——说清何时使用示例可运行——代码能编译、能执行链接有效——Related Skills 中引用的技能真实存在无敏感数据——不包含 API Key、令牌、路径等。8.3 代码示例的编译/语法验证# 从仓库根目录 npx tsc --noEmit skills/your-skill-name/examples/*.ts # 或在技能目录内 npx tsc --noEmit examples/*.ts # 从仓库根目录 python -m py_compile skills/your-skill-name/examples/*.py # 或在技能目录内 python -m py_compile examples/*.py # 从仓库根目录 go build ./skills/your-skill-name/examples/... # 或在技能目录内 go build ./examples/...提交前可用仓库现成的校验脚本做一次模拟 CI该脚本会扫描全部技能并输出统计与告警# 对 Frontmatter 做严格校验把发现升级为 ERROR CI_STRICT_SKILLS1 node scripts/ci/validate-skills.js九、提交你的技能含 PR 模板1. Fork 并 Clone将本仓库或目标上游仓库fork 到自己的账号后克隆到本地。若以当前仓库为上游直接执行git clone https://gitcode.com/GitHub_Trending/ev/ECC cd ECC2. 创建功能分支git checkout -b feat/skill-your-skill-name3. 添加技能目录mkdir -p skills/your-skill-name # Create SKILL.md4. 本地验证# 检查 YAML Frontmatter head -10 skills/your-skill-name/SKILL.md # 确认目录结构 ls -la skills/your-skill-name/ # 如有测试则运行 npm test5. 提交并推送git add skills/your-skill-name/ git commit -m feat(skills): add your-skill-name skill git push -u origin feat/skill-your-skill-name6. 创建 Pull Request使用如下 PR 模板## Summary Brief description of the skill and why its valuable. ## Skill Type - [ ] Language standards - [ ] Framework patterns - [ ] Workflow - [ ] Domain knowledge - [ ] Tool integration ## Testing How I tested this skill locally. ## Checklist - [ ] YAML frontmatter valid - [ ] Code examples tested - [ ] Follows skill guidelines - [ ] No sensitive data - [ ] Clear activation triggers十、Examples Gallery三份完整范例拆解范例 1语言标准类仓库实存skills/rust-patterns/SKILL.md--- name: rust-patterns description: Rust idioms, ownership patterns, and best practices for safe, idiomatic code. origin: ECC --- # Rust Patterns ## When to Activate - Writing Rust code - Handling ownership and borrowing - Error handling with Result/Option - Implementing traits ## Ownership Patterns ### Borrowing Rules rust // PASS: CORRECT: Borrow when you dont need ownership fn process_data(data: str) - usize { data.len() } // PASS: CORRECT: Take ownership when you need to modify or consume fn consume_data(data: Vecu8) - String { String::from_utf8(data).unwrap() } ## Error Handling ### Result Pattern rust use thiserror::Error; #[derive(Error, Debug)] pub enum AppError { #[error(IO error: {0})] Io(#[from] std::io::Error), #[error(Parse error: {0})] Parse(#[from] std::num::ParseIntError), } pub type AppResultT ResultT, AppError; ## Related Skills - rust-testing - rust-security范例 2框架模式类仓库实存skills/fastapi-patterns/SKILL.md--- name: fastapi-patterns description: FastAPI patterns for routing, dependency injection, validation, and async operations. origin: ECC --- # FastAPI Patterns ## When to Activate - Building FastAPI applications - Creating API endpoints - Implementing dependency injection - Handling async database operations ## Project Structure app/ ├── main.py # FastAPI app entry point ├── routers/ # Route handlers │ ├── users.py │ └── items.py ├── models/ # Pydantic models │ ├── user.py │ └── item.py ├── services/ # Business logic │ └── user_service.py └── dependencies.py # Shared dependencies ## Dependency Injection python from fastapi import Depends from sqlalchemy.ext.asyncio import AsyncSession async def get_db() - AsyncSession: async with AsyncSessionLocal() as session: yield session router.get(/users/{user_id}) async def get_user( user_id: int, db: AsyncSession Depends(get_db) ): # Use db session pass ## Related Skills - python-patterns - pydantic-validation范例 3工作流类refactoring-workflow模板说明该范例在本指南中作为工作流技能的推荐模板给出当前仓库skills/目录并未收录同名技能需要对照真实实现时可研读同为工作流类的 skills/tdd-workflow/SKILL.md。--- name: refactoring-workflow description: Systematic refactoring workflow for improving code quality without changing behavior. origin: ECC --- # Refactoring Workflow ## When to Activate - Improving code structure - Reducing technical debt - Simplifying complex code - Extracting reusable components ## Prerequisites - All tests passing - Git working directory clean - Feature branch created ## Workflow Steps ### Step 1: Identify Refactoring Target - Look for code smells (long methods, duplicate code, large classes) - Check test coverage for target area - Document current behavior ### Step 2: Ensure Tests Exist bash # Run tests to verify current behavior npm test # Check coverage for target files npm run test:coverage ### Step 3: Make Small Changes - One refactoring at a time - Run tests after each change - Commit frequently ### Step 4: Verify Behavior Unchanged bash # Run full test suite npm test # Run E2E tests npm run test:e2e ## Common Refactorings | Smell | Refactoring | |-------|-------------| | Long method | Extract method | | Duplicate code | Extract to shared function | | Large class | Extract class | | Long parameter list | Introduce parameter object | ## Checklist - [ ] Tests exist for target code - [ ] Made small, focused changes - [ ] Tests pass after each change - [ ] Behavior unchanged - [ ] Committed with clear message 【免费下载链接】ECCThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.项目地址: https://gitcode.com/GitHub_Trending/ev/ECC创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表