Agent skill
example
Saves reusable code examples to the examples library with metadata and tags.
Install this agent skill to your Project
npx add-skill https://github.com/goffity/claude-km-skill/tree/main/skills/example
SKILL.md
Example - Code Examples Library
Save and organize reusable code snippets with metadata.
Usage
/example [language] [name]
Output: $PROJECT_ROOT/docs/examples/[language]/[name].[ext]
Instructions
- Parse arguments: language (go, typescript, python, bash, etc.) and name (kebab-case)
- Determine file extension from language:
- go → .go
- typescript/ts → .ts
- javascript/js → .js
- python/py → .py
- bash/sh → .sh
- rust → .rs
- java → .java
- Gather context: Look at recent code in conversation, ask user what code to save if unclear
- Create directory:
docs/examples/[language]/ - Generate file with metadata header and code
- Confirm with user
File Format
Go Example
// Title: [Descriptive Title]
// Tags: [tag1, tag2, tag3]
// Related: [link to knowledge-base or learnings if any]
// Created: YYYY-MM-DD
package examples
// [Description of what this code does]
// Usage:
// [usage example]
[code]
TypeScript/JavaScript Example
// Title: [Descriptive Title]
// Tags: [tag1, tag2, tag3]
// Related: [link to knowledge-base if any]
// Created: YYYY-MM-DD
// [Description]
// Usage:
// [usage example]
[code]
Python Example
# Title: [Descriptive Title]
# Tags: [tag1, tag2, tag3]
# Related: [link to knowledge-base if any]
# Created: YYYY-MM-DD
# [Description]
# Usage:
# [usage example]
[code]
Bash Example
#!/bin/bash
# Title: [Descriptive Title]
# Tags: [tag1, tag2, tag3]
# Related: [link to knowledge-base if any]
# Created: YYYY-MM-DD
# [Description]
# Usage:
# [usage example]
[code]
Guidelines
- Code should be runnable or at minimum compilable
- Include usage examples in comments
- Add relevant tags for searchability
- Link to related knowledge-base entries if they exist
- Keep examples focused on one concept/pattern
- Use descriptive names (e.g.,
retry-with-backoff,api-client-wrapper)
Listing Examples
To browse existing examples:
find docs/examples -type f | sort
Related Commands
| Command | Purpose |
|---|---|
/mem |
Quick knowledge capture |
/distill |
Extract patterns to knowledge base |
/example |
Save code examples (you are here) |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
commit
Creates atomic commits by invoking TDG and commenting on related GitHub issues.
distill
Synthesizes related learnings into reusable knowledge base patterns.
security-auditor
Audits code for security vulnerabilities including OWASP Top 10 and authentication issues.
code-reviewer
Reviews code changes for bugs, security vulnerabilities, and performance issues.
flow
Documents workflow diagrams and process flows with Mermaid diagram support.
share
Shares knowledge across projects by copying to shared-knowledge directory with cross-project metadata.
Didn't find tool you were looking for?