Claude
Skills
Sign in
Back

bad-example-skill

Included with Lifetime
$97 forever

ANTI-PATTERN - Example showing violations of self-containment (DO NOT COPY)

frameworkanti-patternbad-exampleviolations

What this skill does

# ⚠️ BAD EXAMPLE - Interdependent Skill (Anti-Pattern)

**WARNING**: This is an **ANTI-PATTERN** example showing what NOT to do.

**DO NOT COPY THIS STRUCTURE**. See [good-self-contained-skill](../good-self-contained-skill/) for correct approach.

---

## ❌ VIOLATION #1: Relative Path Dependencies

```markdown
## 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**:
- ❌ Uses relative paths (`../`, `../../`)
- ❌ Assumes hierarchical directory structure
- ❌ Breaks in flat deployment (`~/.claude/skills/`)
- ❌ Links break when skill deployed standalone

**Correct Approach**:
```markdown
## 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.*
```

---

## ❌ VIOLATION #2: Missing Essential Content

```markdown
## 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**:
- ❌ No actual testing patterns included
- ❌ Requires user to have another skill
- ❌ Skill is incomplete without other skills
- ❌ "See other skill" instead of inlining

**Correct Approach**:
```markdown
## 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):
- Parametrized fixtures
- Database session fixtures
- Mock fixtures

*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
```

## Complementary Skills

When using this skill, consider (if deployed):
- **setup-skill**: Advanced configuration patterns (optional)
- **database-skill**: ORM patterns and optimization (optional)
- **pytest-patterns**: Testing enhancements (optional)

*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**:
- ❌ Imports from other skills
- ❌ Code won't run without other skills
- ❌ Creates runtime dependencies
- ❌ Violates Python module boundaries

**Correct Approach**:
```python
"""
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()
```

---

## ❌ VIOLATION #5: Hierarchical Directory Assumptions

```markdown
## 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**:
- ❌ Assumes specific directory structure
- ❌ Navigation instructions using relative paths
- ❌ Won't work in flat deployment
- ❌ Confuses deployment location with skill relationships

**Correct Approach**:
```markdown
## 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.*
```

---

## ❌ VIOLATION #6: Incomplete Examples

```python
# 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**:
- ❌ Examples are fragments, not complete code
- ❌ "See other skill" instead of showing code
- ❌ Users can't copy-paste and run
- ❌ Skill provides no actual implementation guidance

**Correct Approach**:
```python
# 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": "[email protected]"
    })
    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
```

---

## ❌ VIOLATION #7: References Directory with Cross-Skill Paths

```
bad-example-skill/
├── SKILL.md
├── metadata.json
└── references/
    ├── testing.md          # Contains: ../../pytest-patterns/
    ├── database.md         # Contains: ../../database-skill/
    └── deployment.md       # Contains: ../../../universal/deployment/
```

**refer

Related in framework