Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:36:05 +08:00
commit 0795c78068
10 changed files with 1371 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
---
name: code-cleanup
description: Delegate repetitive tasks to specialized agent to preserve context. Use when user asks to fix linting errors, fix diagnostics, rename variables across files, update imports, fix formatting issues, or perform other mechanical bulk changes across multiple files.
---
# Delegate to Code Janitor
When you encounter **repetitive, mechanical code tasks**, launch the `code-janitor` agent instead of doing the work yourself to preserve context.
## Delegate When:
- Fixing multiple linting errors across files
- Renaming variables/functions consistently across codebase
- Updating import statements in multiple files
- Fixing formatting or style violations throughout project
- Resolving IDE diagnostics in batch
- Bulk refactoring that doesn't require design decisions
## Keep in Main When:
- Task requires architectural decisions
- Single file with 1-2 changes
- User explicitly wants you to do it
## How:
Use Task tool with `subagent_type: "essentials:code-janitor"` providing task description and scope.
The code-janitor agent uses TodoWrite to track work, iterates until complete, and verifies with linters.

View File

@@ -0,0 +1,60 @@
---
name: code-examples
description: Find real-world code examples across millions of GitHub repositories. Use when the user wants to see how others implement something, find usage patterns, or discover code examples in the wild.
---
# Code Examples
Find real-world code examples across millions of public GitHub repositories using grep.app.
**When to activate:**
- User wants to see real-world code examples
- User asks "how do others implement X?"
- User wants to find usage patterns for a library/API
- User needs production code examples (not docs)
**API endpoint:**
```bash
curl -s "https://grep.app/api/search?q={query}&page=1" | jq '.hits.hits[:5]'
```
**Parameters:**
| Parameter | Description |
| ---------------- | --------------------------------------------------------------------- |
| `q` | Search query (required) |
| `page` | Page number for pagination |
| `regexp` | `true` for regex search |
| `case` | `true` for case-sensitive |
| `f.lang` | Language filter (**capitalized**, e.g., `TypeScript`, `Go`, `Python`) |
| `f.repo.pattern` | Filter by repository pattern |
| `f.path.pattern` | Filter by file path pattern |
**Examples:**
Search for useEffect usage in TypeScript:
```bash
curl -s "https://grep.app/api/search?q=useEffect&f.lang=TypeScript&page=1" | jq '.hits.hits[:3]'
```
Search for Go error handling patterns:
```bash
curl -s "https://grep.app/api/search?q=if%20err%20!=%20nil&f.lang=Go&page=1" | jq '.hits.hits[:3]'
```
Search within a specific repo:
```bash
curl -s "https://grep.app/api/search?q=createContext&f.repo.pattern=facebook/react&page=1" | jq '.hits.hits[:3]'
```
**Response format:**
- `hits.hits[]` - Array of search results
- Each hit contains: `repo.raw` (repo name), `path.raw` (file path), `content.snippet` (code snippet)
**Note:** Returns max 1000 results. For documentation, use the documentation-lookup skill instead.

View File

@@ -0,0 +1,54 @@
---
name: documentation-lookup
description: Look up library and framework documentation. Use when the user asks about API docs, library usage, framework features, or mentions specific libraries/packages by name.
---
# Documentation Lookup
**When to activate:**
- User says "check the docs"
- User needs API documentation or code examples
- User mentions a library/framework name
- Source code of a library is not available locally
**Two-step process:**
## Step 1: Find the library ID
Search for the library to get its context7 ID:
```bash
curl -s "https://context7.com/api/v2/search?query={library_name}" | jq '.results[:3]'
```
**Example - searching for "react":**
```bash
curl -s "https://context7.com/api/v2/search?query=react" | jq '.results[:3] | .[] | {id, title}'
```
This returns matching libraries. Use the `id` field (e.g., `/facebook/react` or `/websites/react_dev`).
## Step 2: Fetch documentation
Use the library ID from step 1:
```bash
curl -s "https://context7.com/api/v2/docs/code{library_id}?topic={topic}&page=1"
```
**Example - fetching React hooks docs:**
```bash
curl -s "https://context7.com/api/v2/docs/code/facebook/react?topic=hooks&page=1"
```
**Parameters:**
- `topic` - Focus area (e.g., `hooks`, `routing`, `authentication`)
- `page` - Pagination (1-10), use if first page doesn't have enough info
**Response:** Returns markdown-formatted documentation snippets with code examples.
**Fallback:** If context7 doesn't have the library or returns errors, use web search.