agentleFS
ebibibiebibibi/claude-code-discord-bridge/.claude/skills/add-cog/SKILL.md

add-cog

Skill66 starsChanged 9 months agoMITView on GitHub

Step-by-step guide to add a new discord.py Cog to the framework

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When asked to "add a cog", "create a command", or "add a feature"

    line 12
  2. Distinctive:

    Use the shared helper — never duplicate the streaming logic:

    line 49
  3. Distinctive:

    Test command validation (invalid inputs, edge cases)

    line 84
  4. Distinctive:

    Test error handling paths

    line 87
  5. Distinctive:

    Run the verify skill to ensure everything passes:

    line 91
  6. Very specific:

    Logging: Use logger = logging.getLogger(__name__), never print()

    line 103
  7. Very specific:

    Authorization: If the Cog accepts user commands, check _is_authorized(user_id)

    line 104
  8. Very specific:

    Error handling: Use contextlib.suppress(discord.HTTPException) for non-critical Discord API calls

    line 106

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add Cog — Scaffold a New Discord.py Cog

When to Activate

  • Adding new Discord bot functionality
  • Creating a new slash command or event handler
  • When asked to "add a cog", "create a command", or "add a feature"

Steps

1. Create the Cog File

Create claude_discord/cogs/your_cog.py:

"""Short description of what this Cog does."""

from __future__ import annotations

import logging

import discord
from discord import app_commands
from discord.ext import commands

logger = logging.getLogger(__name__)


class YourCog(commands.Cog):
    """Docstring explaining the Cog's purpose."""

    def __init__(
        self,
        bot: commands.Bot,
        # Add dependencies as constructor params (dependency injection)
    ) -> None:
        self.bot = bot

    # Add commands and listeners here

2. If It Runs Claude CLI

Use the shared helper — never duplicate the streaming logic:

from ._run_helper import run_claude_in_thread

# In your command handler:
runner = self.runner.clone()  # Always clone for concurrent safety
await run_claude_in_thread(
    thread=thread,
    runner=runner,
    repo=self.repo,
    prompt=user_input,
    session_id=existing_session_id,
)

3. Export from Package

Add to claude_discord/cogs/__init__.py:

from .your_cog import YourCog

Add to claude_discord/__init__.py:

from .cogs.your_cog import YourCog
# And add "YourCog" to __all__

4. Write Tests

Create tests/test_your_cog.py:

  • Test command validation (invalid inputs, edge cases)
  • Test authorization checks
  • Mock Discord objects (discord.Interaction, discord.TextChannel, etc.)
  • Test error handling paths

5. Verify

Run the verify skill to ensure everything passes:

uv run ruff check claude_discord/
uv run ruff format claude_discord/
uv run pytest tests/ -v --cov=claude_discord

Conventions

  • Type hints: Required on all function signatures
  • from __future__ import annotations: Required in every file
  • Logging: Use logger = logging.getLogger(__name__), never print()
  • Authorization: If the Cog accepts user commands, check _is_authorized(user_id)
  • Input validation: Validate all user-provided strings with regex before passing to subprocess
  • Error handling: Use contextlib.suppress(discord.HTTPException) for non-critical Discord API calls

Download now (ZIP)

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. ebibibi/ebi-agent-chat-relay★ 66100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository9 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.