bad-example-skill by bobmatnyc/claude-mpm-skills
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill bad-example-skill警告:这是一个反模式示例,展示了不应该做的事情。
请勿复制此结构。正确的做法请参阅 good-self-contained-skill。
## 相关文档
有关设置说明,请参阅 [../setup-skill/SKILL.md](../setup-skill/SKILL.md)
有关测试模式,请参阅:
- [../../testing/pytest-patterns/](../../testing/pytest-patterns/)
- [../../testing/test-utils/](../../testing/test-utils/)
数据库集成:[../../data/database-skill/](../../data/database-skill/)
错误原因:
../、../../)~/.claude/skills/)中会失效:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
## 互补技能
考虑以下相关技能(如果已部署):
- **setup-skill**:安装和配置模式
- **pytest-patterns**:测试框架和夹具
- **database-skill**:数据库集成模式
*注意:所有技能均可独立部署。*
## 测试
本技能使用 pytest 进行测试。
**所有测试代码请参阅 pytest-patterns 技能。**
要为该框架编写测试,请安装 pytest-patterns 技能
并参考其文档。
错误原因:
正确做法:
## 测试(自包含)
**核心 pytest 模式**(内联):
```python
import pytest
from example_framework.testing import TestClient
@pytest.fixture
def client():
"""测试客户端夹具。"""
return TestClient(app)
def test_home_route(client):
"""测试主页。"""
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello"}
高级夹具(如果已部署 pytest-patterns 技能):
有关全面的模式,请参阅 pytest-patterns 技能。
---
## ❌ 违规 #3:硬性技能依赖
```markdown
## 先决条件
**必需技能**:
1. **setup-skill** - 必须首先安装
2. **database-skill** - 数据库操作所必需
3. **pytest-patterns** - 测试所必需
使用本技能前,请安装所有必需技能:
```bash
claude-code skills add setup-skill database-skill pytest-patterns
没有这些依赖项,本技能将无法工作。
**错误原因**:
- ❌ 将其他技能列为“必需”
- ❌ 技能无法独立运行
- ❌ 造成部署耦合
- ❌ 违反自包含原则
**正确做法**:
```markdown
## 先决条件
**外部依赖项**:
```bash
pip install example-framework pytest sqlalchemy
使用本技能时,可考虑(如果已部署):
本技能完全独立运行。
---
## ❌ 违规 #4:跨技能导入
```python
"""
反面示例 - 从其他技能导入。
"""
# ❌ 不要这样做
from skills.database_skill import get_db_session
from skills.pytest_patterns import fixture_factory
from ..shared.utils import validate_input
# 使用导入的模式
@app.route("/users")
def create_user(data):
# 需要安装 database-skill
with get_db_session() as session:
user = User(**data)
session.add(user)
return user.to_dict()
错误原因:
正确做法:
"""
正面示例 - 自包含的实现。
"""
from contextlib import contextmanager
# ✅ 将模式直接包含在本技能中
@contextmanager
def get_db_session():
"""数据库会话上下文管理器(自包含)。"""
db = SessionLocal()
try:
yield db
db.commit()
except Exception:
db.rollback()
raise
finally:
db.close()
@app.route("/users")
def create_user(data):
# 独立运行
with get_db_session() as session:
user = User(**data)
session.add(user)
return user.to_dict()
## 项目结构
本技能位于:
toolchains/python/frameworks/bad-example-skill/
**导航到父目录以访问相关技能**:
- `../` - 其他框架技能
- `../../testing/` - 测试技能
- `../../data/` - 数据库技能
**`toolchains/python/frameworks/` 中的所有技能都与本技能相关。**
错误原因:
正确做法:
## 相关技能
**互补的 Python 框架技能**(信息性):
- **fastapi-patterns**:Web 框架模式
- **django-patterns**:全栈框架模式
- **flask-patterns**:微框架模式
**测试技能**:
- **pytest-patterns**:测试框架
- **test-driven-development**:TDD 工作流
*注意:技能可独立部署。目录结构可能有所不同。*
# 数据库设置
# (完整实现请参阅 database-skill)
class User(db.Model):
# ... 模型定义请参阅 database-skill ...
pass
# 测试
# (测试示例请参阅 pytest-patterns)
def test_user():
# ... 夹具请参阅 pytest-patterns ...
pass
# 部署
# (生产环境设置请参阅 deployment-skill)
错误原因:
正确做法:
# 完整的数据库模型(自包含)
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
"""用户模型 - 完整实现。"""
__tablename__ = "users"
id = Column(Integer, primary_key=True)
username = Column(String(80), unique=True, nullable=False)
email = Column(String(120), unique=True, nullable=False)
def to_dict(self):
return {
"id": self.id,
"username": self.username,
"email": self.email
}
# 完整的测试示例(自包含)
import pytest
from example_framework.testing import TestClient
@pytest.fixture
def client():
return TestClient(app)
def test_create_user(client):
"""测试用户创建 - 完整可运行的测试。"""
response = client.post("/users", json={
"username": "testuser",
"email": "test@example.com"
})
assert response.status_code == 201
assert response.json()["username"] == "testuser"
# 完整的部署示例(自包含)
import os
class ProductionConfig:
DEBUG = False
SECRET_KEY = os.getenv("SECRET_KEY")
DATABASE_URL = os.getenv("DATABASE_URL")
app = App(config=ProductionConfig())
# 运行命令:gunicorn -w 4 app:app
bad-example-skill/
├── SKILL.md
├── metadata.json
└── references/
├── testing.md # 包含:../../pytest-patterns/
├── database.md # 包含:../../database-skill/
└── deployment.md # 包含:../../../universal/deployment/
references/testing.md 包含:
# 测试模式
完整的测试模式,请参阅:
- [Pytest 模式](../../pytest-patterns/SKILL.md)
- [TDD 工作流](../../../universal/testing/test-driven-development/)
所有测试代码请参考这些技能。
错误原因:
正确做法:
good-example-skill/
├── SKILL.md
├── metadata.json
└── references/
├── advanced-patterns.md # 关于本技能的所有内容
├── api-reference.md # 本技能的 API
└── examples.md # 本技能的示例
references/advanced-patterns.md 应包含:
# 高级测试模式
**高级 pytest 夹具**(本技能):
```python
# 参数化测试夹具
@pytest.fixture(params=["value1", "value2"])
def data_variants(request):
return request.param
def test_with_variants(data_variants):
# 使用多种数据变体进行测试
assert process(data_variants) is not None
进一步的增强功能(如果已部署 pytest-patterns):
有关全面的高级模式,请参阅 pytest-patterns 技能。
---
## ❌ 违规 #8:metadata.json 包含技能依赖
```json
{
"name": "bad-example-skill",
"version": "1.0.0",
"requires": [
"setup-skill",
"database-skill",
"pytest-patterns"
],
"self_contained": false,
"dependencies": ["example-framework"],
"notes": [
"本技能需要先安装 setup-skill",
"必须与 database-skill 一起部署以进行数据库操作",
"没有 pytest-patterns 进行测试则无法工作"
]
}
错误原因:
"self_contained": false正确做法:
{
"name": "good-example-skill",
"version": "1.0.0",
"requires": [],
"self_contained": true,
"dependencies": ["example-framework", "pytest", "sqlalchemy"],
"complementary_skills": [
"setup-skill",
"database-skill",
"pytest-patterns"
],
"notes": [
"本技能完全自包含,可独立运行",
"所有核心模式均已内联",
"互补技能提供可选的增强功能"
]
}
| 违规项 | 示例 | 影响 |
|---|---|---|
| 相对路径 | ../../other-skill/ | 在扁平化部署中失效 |
| 缺少内容 | "X 请参阅其他技能" | 不完整,无法自给自足 |
| 硬性依赖 | "需要 other-skill" | 无法独立部署 |
| 跨技能导入 | from skills.other import | 运行时依赖 |
| 层级假设 | "导航到父目录" | 位置依赖 |
| 不完整示例 | 仅代码片段 | 不可用 |
| 引用跨技能 | references/ 包含 ../ | 渐进式披露被破坏 |
| 元数据依赖 | "requires": ["skill"] | 部署耦合 |
# 查找违规项
grep -r "\.\\./" bad-example-skill/
# 移除它们 - 改用技能名称
# ❌ [skill](../../skill/SKILL.md)
# ✅ skill (如果已部署)
# 之前(错误):
## 测试
所有测试代码请参阅 pytest-patterns 技能。
# 之后(正确):
## 测试(自包含)
**核心模式**(内联):
[20-50 行实际的测试代码]
**高级模式**(如果已部署 pytest-patterns):
- 功能列表
*全面指南请参阅 pytest-patterns。*
# 之前(错误):
**必需技能**:pytest-patterns, database-skill
# 之后(正确):
**互补技能**(可选):
- pytest-patterns:测试增强功能
- database-skill:ORM 优化
# 之前(错误):
from skills.database import get_db_session
# 之后(正确):
@contextmanager
def get_db_session():
"""内联模式。"""
# 此处实现
// 之前(错误):
{
"requires": ["other-skill"],
"self_contained": false
}
// 之后(正确):
{
"requires": [],
"self_contained": true,
"complementary_skills": ["other-skill"]
}
修复后,验证自包含性:
# 应返回空(无违规项)
grep -r "\.\\./" skill-name/
grep -r "from skills\." skill-name/
grep -i "requires.*skill" skill-name/SKILL.md
# 隔离测试
cp -r skill-name /tmp/skill-test/
cd /tmp/skill-test/skill-name
cat SKILL.md # 应完整且有用
# 元数据检查
cat metadata.json | jq '.requires' # 应为 [] 或仅外部包
请勿将此示例用作模板
请参阅:
请记住:此示例展示了不应该做的事情。请始终确保你的技能是自包含的!
每周安装次数
65
代码仓库
GitHub 星标数
18
首次出现
2026 年 1 月 23 日
安全审计
安装于
claude-code50
opencode49
codex49
gemini-cli48
cursor46
github-copilot46
WARNING : This is an ANTI-PATTERN example showing what NOT to do.
DO NOT COPY THIS STRUCTURE. See good-self-contained-skill for correct approach.
## Related Documentation
For setup instructions, see [../setup-skill/SKILL.md](../setup-skill/SKILL.md)
For testing patterns, see:
- [../../testing/pytest-patterns/](../../testing/pytest-patterns/)
- [../../testing/test-utils/](../../testing/test-utils/)
Database integration: [../../data/database-skill/](../../data/database-skill/)
Why This is Wrong :
../, ../../)~/.claude/skills/)Correct Approach :
## Complementary Skills
Consider these related skills (if deployed):
- **setup-skill**: Installation and configuration patterns
- **pytest-patterns**: Testing framework and fixtures
- **database-skill**: Database integration patterns
*Note: All skills are independently deployable.*
## Testing
This skill uses pytest for testing.
**See pytest-patterns skill for all testing code.**
To write tests for this framework, install pytest-patterns skill
and refer to its documentation.
Why This is Wrong :
Correct Approach :
## Testing (Self-Contained)
**Essential pytest pattern** (inlined):
```python
import pytest
from example_framework.testing import TestClient
@pytest.fixture
def client():
"""Test client fixture."""
return TestClient(app)
def test_home_route(client):
"""Test homepage."""
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello"}
Advanced fixtures (if pytest-patterns skill deployed):
See pytest-patterns skill for comprehensive patterns.
---
## ❌ VIOLATION #3: Hard Skill Dependencies
```markdown
## Prerequisites
**Required Skills**:
1. **setup-skill** - Must be installed first
2. **database-skill** - Required for database operations
3. **pytest-patterns** - Required for testing
Install all required skills before using this skill:
```bash
claude-code skills add setup-skill database-skill pytest-patterns
This skill will not work without these dependencies.
**Why This is Wrong**:
- ❌ Lists other skills as "Required"
- ❌ Skill doesn't work standalone
- ❌ Creates deployment coupling
- ❌ Violates self-containment principle
**Correct Approach**:
```markdown
## Prerequisites
**External Dependencies**:
```bash
pip install example-framework pytest sqlalchemy
When using this skill, consider (if deployed):
This skill is fully functional independently.
---
## ❌ VIOLATION #4: Cross-Skill Imports
```python
"""
Bad example - importing from other skills.
"""
# ❌ DON'T DO THIS
from skills.database_skill import get_db_session
from skills.pytest_patterns import fixture_factory
from ..shared.utils import validate_input
# Using imported patterns
@app.route("/users")
def create_user(data):
# Requires database-skill to be installed
with get_db_session() as session:
user = User(**data)
session.add(user)
return user.to_dict()
Why This is Wrong :
Correct Approach :
"""
Good example - self-contained implementation.
"""
from contextlib import contextmanager
# ✅ Include pattern directly in this skill
@contextmanager
def get_db_session():
"""Database session context manager (self-contained)."""
db = SessionLocal()
try:
yield db
db.commit()
except Exception:
db.rollback()
raise
finally:
db.close()
@app.route("/users")
def create_user(data):
# Works independently
with get_db_session() as session:
user = User(**data)
session.add(user)
return user.to_dict()
## Project Structure
This skill is located in:
toolchains/python/frameworks/bad-example-skill/
**Navigate to parent directories for related skills**:
- `../` - Other framework skills
- `../../testing/` - Testing skills
- `../../data/` - Database skills
**All skills in `toolchains/python/frameworks/` are related to this skill.**
Why This is Wrong :
Correct Approach :
## Related Skills
**Complementary Python Framework Skills** (informational):
- **fastapi-patterns**: Web framework patterns
- **django-patterns**: Full-stack framework patterns
- **flask-patterns**: Micro-framework patterns
**Testing Skills**:
- **pytest-patterns**: Testing framework
- **test-driven-development**: TDD workflow
*Note: Skills are independently deployable. Directory structure may vary.*
# Database setup
# (See database-skill for complete implementation)
class User(db.Model):
# ... see database-skill for model definition ...
pass
# Testing
# (See pytest-patterns for test examples)
def test_user():
# ... see pytest-patterns for fixtures ...
pass
# Deployment
# (See deployment-skill for production setup)
Why This is Wrong :
Correct Approach :
# Complete database model (self-contained)
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
"""User model - complete implementation."""
__tablename__ = "users"
id = Column(Integer, primary_key=True)
username = Column(String(80), unique=True, nullable=False)
email = Column(String(120), unique=True, nullable=False)
def to_dict(self):
return {
"id": self.id,
"username": self.username,
"email": self.email
}
# Complete test example (self-contained)
import pytest
from example_framework.testing import TestClient
@pytest.fixture
def client():
return TestClient(app)
def test_create_user(client):
"""Test user creation - complete working test."""
response = client.post("/users", json={
"username": "testuser",
"email": "test@example.com"
})
assert response.status_code == 201
assert response.json()["username"] == "testuser"
# Complete deployment example (self-contained)
import os
class ProductionConfig:
DEBUG = False
SECRET_KEY = os.getenv("SECRET_KEY")
DATABASE_URL = os.getenv("DATABASE_URL")
app = App(config=ProductionConfig())
# Run with: gunicorn -w 4 app:app
bad-example-skill/
├── SKILL.md
├── metadata.json
└── references/
├── testing.md # Contains: ../../pytest-patterns/
├── database.md # Contains: ../../database-skill/
└── deployment.md # Contains: ../../../universal/deployment/
references/testing.md contains :
# Testing Patterns
For complete testing patterns, see:
- [Pytest Patterns](../../pytest-patterns/SKILL.md)
- [TDD Workflow](../../../universal/testing/test-driven-development/)
Refer to those skills for all testing code.
Why This is Wrong :
Correct Approach :
good-example-skill/
├── SKILL.md
├── metadata.json
└── references/
├── advanced-patterns.md # All about THIS skill
├── api-reference.md # THIS skill's API
└── examples.md # THIS skill's examples
references/advanced-patterns.md should contain :
# Advanced Testing Patterns
**Advanced pytest fixtures** (this skill):
```python
# Parametrized test fixture
@pytest.fixture(params=["value1", "value2"])
def data_variants(request):
return request.param
def test_with_variants(data_variants):
# Test with multiple data variants
assert process(data_variants) is not None
Further enhancements (if pytest-patterns deployed):
See pytest-patterns skill for comprehensive advanced patterns.
---
## ❌ VIOLATION #8: metadata.json with Skill Dependencies
```json
{
"name": "bad-example-skill",
"version": "1.0.0",
"requires": [
"setup-skill",
"database-skill",
"pytest-patterns"
],
"self_contained": false,
"dependencies": ["example-framework"],
"notes": [
"This skill requires setup-skill to be installed first",
"Must deploy with database-skill for database operations",
"Won't work without pytest-patterns for testing"
]
}
Why This is Wrong :
"self_contained": falseCorrect Approach :
{
"name": "good-example-skill",
"version": "1.0.0",
"requires": [],
"self_contained": true,
"dependencies": ["example-framework", "pytest", "sqlalchemy"],
"complementary_skills": [
"setup-skill",
"database-skill",
"pytest-patterns"
],
"notes": [
"This skill is fully self-contained and works independently",
"All essential patterns are inlined",
"Complementary skills provide optional enhancements"
]
}
| Violation | Example | Impact |
|---|---|---|
| Relative Paths | ../../other-skill/ | Breaks in flat deployment |
| Missing Content | "See other skill for X" | Incomplete, not self-sufficient |
| Hard Dependencies | "Requires other-skill" | Can't deploy standalone |
| Cross-Skill Imports | from skills.other import | Runtime dependency |
| Hierarchical Assumptions | "Navigate to parent dir" | Location-dependent |
| Incomplete Examples | Code fragments only |
# Find violations
grep -r "\.\\./" bad-example-skill/
# Remove them - use skill names instead
# ❌ [skill](../../skill/SKILL.md)
# ✅ skill (if deployed)
# Before (wrong):
## Testing
See pytest-patterns skill for all testing code.
# After (correct):
## Testing (Self-Contained)
**Essential pattern** (inlined):
[20-50 lines of actual testing code]
**Advanced patterns** (if pytest-patterns deployed):
- Feature list
*See pytest-patterns for comprehensive guide.*
# Before (wrong):
**Required Skills**: pytest-patterns, database-skill
# After (correct):
**Complementary Skills** (optional):
- pytest-patterns: Testing enhancements
- database-skill: ORM optimization
# Before (wrong):
from skills.database import get_db_session
# After (correct):
@contextmanager
def get_db_session():
"""Inlined pattern."""
# Implementation here
// Before (wrong):
{
"requires": ["other-skill"],
"self_contained": false
}
// After (correct):
{
"requires": [],
"self_contained": true,
"complementary_skills": ["other-skill"]
}
After fixing, verify self-containment:
# Should return empty (no violations)
grep -r "\.\\./" skill-name/
grep -r "from skills\." skill-name/
grep -i "requires.*skill" skill-name/SKILL.md
# Isolation test
cp -r skill-name /tmp/skill-test/
cd /tmp/skill-test/skill-name
cat SKILL.md # Should be complete and useful
# Metadata check
cat metadata.json | jq '.requires' # Should be [] or external packages only
DO NOT USE THIS EXAMPLE AS A TEMPLATE
Instead, see:
Remember : This example shows what NOT to do. Always ensure your skills are self-contained!
Weekly Installs
65
Repository
GitHub Stars
18
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code50
opencode49
codex49
gemini-cli48
cursor46
github-copilot46
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
122,000 周安装
| Not usable |
| References Cross-Skill | references/ has ../ | Progressive disclosure broken |
| Metadata Dependencies | "requires": ["skill"] | Deployment coupling |