@workingpayload/agent-skills 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CodeMap/skill.md +194 -0
- package/README.md +440 -416
- package/RefactorX/skill.md +27 -1
- package/bin/cli.js +91 -29
- package/package.json +3 -2
- package/scripts/doctor.py +5 -4
- package/scripts/install.py +57 -17
- package/scripts/test_skill.py +30 -2
- package/skills-routing.json +27 -2
- package/skills.json +132 -4
package/CodeMap/skill.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codemap
|
|
3
|
+
description: Generates and maintains a structured codemap file that gives AI agents instant codebase context without costly exploration. Produces a navigable index of entry points, modules, key abstractions, dependency flow, and file roles. Use when starting a new session, after major refactors, at PR boundaries, or when an agent is burning context on repeated file discovery.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CodeMap
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Generates a `.codemap.md` file at the repository root — a structured index that gives AI agents instant codebase orientation without spending tokens on exploration. Regenerated at **checkpoints**: session start, post-merge, post-refactor, or on demand.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Workflow
|
|
15
|
+
|
|
16
|
+
### 1. Discover Project Shape
|
|
17
|
+
|
|
18
|
+
Scan the repo to determine language(s) (from `package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`), framework (React, FastAPI, Spring Boot, etc.), monorepo layout (`workspaces`, `packages/`, `apps/`), and build system (`Makefile`, `docker-compose.yml`, CI config).
|
|
19
|
+
|
|
20
|
+
Build a file tree via `glob`. Exclude: `node_modules`, `.git`, `dist`, `build`, `__pycache__`, `.venv`, `vendor`, `coverage`, `.next`.
|
|
21
|
+
|
|
22
|
+
### 2. Classify Files by Role
|
|
23
|
+
|
|
24
|
+
Assign each significant file one or more roles:
|
|
25
|
+
|
|
26
|
+
| Role | Description | Examples |
|
|
27
|
+
|------|-------------|----------|
|
|
28
|
+
| **entry** | Application entry point | `main.py`, `index.ts`, `cmd/server/main.go`, `App.tsx` |
|
|
29
|
+
| **route** | HTTP/API route definitions | `routes/*.py`, `app/api/**/*.ts`, `controllers/` |
|
|
30
|
+
| **model** | Data models / schemas / types | `models/`, `schema.prisma`, `types.ts`, `entities/` |
|
|
31
|
+
| **service** | Business logic layer | `services/`, `usecases/`, `domain/` |
|
|
32
|
+
| **repo** | Data access / database layer | `repositories/`, `dal/`, `db/queries/` |
|
|
33
|
+
| **config** | Configuration and env setup | `config/`, `settings.py`, `.env.example`, `next.config.js` |
|
|
34
|
+
| **test** | Test files | `tests/`, `__tests__/`, `*_test.go`, `*.spec.ts` |
|
|
35
|
+
| **migration** | Database migrations | `migrations/`, `alembic/versions/`, `prisma/migrations/` |
|
|
36
|
+
| **infra** | Infrastructure / deployment | `Dockerfile`, `k8s/`, `terraform/`, `docker-compose.yml` |
|
|
37
|
+
| **script** | Build/dev/CI scripts | `scripts/`, `Makefile`, `bin/` |
|
|
38
|
+
| **ui** | Frontend components | `components/`, `pages/`, `views/`, `templates/` |
|
|
39
|
+
| **middleware** | Request/response interceptors | `middleware/`, `interceptors/` |
|
|
40
|
+
| **util** | Shared utilities / helpers | `utils/`, `lib/`, `helpers/`, `common/` |
|
|
41
|
+
|
|
42
|
+
Skip files under 5 lines (empty stubs) and auto-generated files (note them as `[generated]`).
|
|
43
|
+
|
|
44
|
+
### 3. Map Key Abstractions
|
|
45
|
+
|
|
46
|
+
For each module/package, identify:
|
|
47
|
+
|
|
48
|
+
- **Exported interfaces / classes / functions**: the public API surface.
|
|
49
|
+
- **Primary responsibility**: one sentence.
|
|
50
|
+
- **Key dependencies**: what it imports from other internal modules (not third-party).
|
|
51
|
+
|
|
52
|
+
Use this to build a **dependency graph** section showing how modules connect:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
auth/service.py → db/user_repo.py → models/user.py
|
|
56
|
+
→ utils/jwt.py
|
|
57
|
+
→ config/settings.py
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 4. Identify Hot Paths
|
|
61
|
+
|
|
62
|
+
Mark the most-changed files using `git log --format='' --name-only | sort | uniq -c | sort -rn | head -20`. These are the files an agent will most likely need to modify.
|
|
63
|
+
|
|
64
|
+
Also flag:
|
|
65
|
+
- Files with the most imports (high fan-in = critical shared code).
|
|
66
|
+
- Files with the most outgoing imports (high fan-out = potential god modules).
|
|
67
|
+
- Files touched in the last 5 commits (active work area).
|
|
68
|
+
|
|
69
|
+
### 5. Generate the Codemap
|
|
70
|
+
|
|
71
|
+
Write `.codemap.md` at the repository root with this structure:
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
# Codemap
|
|
75
|
+
> Auto-generated at <ISO-8601 timestamp>. Checkpoint: <reason>.
|
|
76
|
+
|
|
77
|
+
## Project
|
|
78
|
+
- **Language**: TypeScript, Python
|
|
79
|
+
- **Framework**: Next.js 14 (App Router), FastAPI
|
|
80
|
+
- **Package manager**: pnpm, uv
|
|
81
|
+
- **Monorepo**: yes (apps/web, apps/api, packages/shared)
|
|
82
|
+
|
|
83
|
+
## Directory Map
|
|
84
|
+
```
|
|
85
|
+
apps/
|
|
86
|
+
web/ # Next.js frontend [entry: app/layout.tsx]
|
|
87
|
+
app/ # App Router pages and layouts [ui]
|
|
88
|
+
components/ # React components [ui]
|
|
89
|
+
lib/ # Client utilities [util]
|
|
90
|
+
api/ # FastAPI backend [entry: main.py]
|
|
91
|
+
routes/ # API endpoints [route]
|
|
92
|
+
services/ # Business logic [service]
|
|
93
|
+
models/ # SQLAlchemy models [model]
|
|
94
|
+
repositories/ # Data access [repo]
|
|
95
|
+
packages/
|
|
96
|
+
shared/ # Shared types and constants [util]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Entry Points
|
|
100
|
+
| File | Role | Description |
|
|
101
|
+
|------|------|-------------|
|
|
102
|
+
| `apps/web/app/layout.tsx` | entry | Root layout, providers, global CSS |
|
|
103
|
+
| `apps/api/main.py` | entry | FastAPI app factory, middleware, router mount |
|
|
104
|
+
| `apps/api/worker.py` | entry | Celery worker bootstrap |
|
|
105
|
+
|
|
106
|
+
## Module Map
|
|
107
|
+
### apps/api/services/auth.py [service]
|
|
108
|
+
- **Does**: Handles login, signup, token refresh, password reset.
|
|
109
|
+
- **Exports**: `authenticate_user()`, `create_tokens()`, `refresh_access_token()`
|
|
110
|
+
- **Depends on**: `repositories/user_repo`, `models/user`, `utils/jwt`, `config/settings`
|
|
111
|
+
|
|
112
|
+
### apps/web/lib/api-client.ts [util]
|
|
113
|
+
- **Does**: Typed fetch wrapper for all API calls.
|
|
114
|
+
- **Exports**: `apiClient`, `useQuery` wrappers
|
|
115
|
+
- **Depends on**: `packages/shared/types`
|
|
116
|
+
|
|
117
|
+
## Dependency Flow
|
|
118
|
+
```
|
|
119
|
+
[web] app/page.tsx → lib/api-client.ts → [api] routes/auth.py → services/auth.py → repositories/user_repo.py → models/user.py
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Hot Files (most changed, last 30 days)
|
|
123
|
+
| File | Changes | Last touched |
|
|
124
|
+
|------|---------|-------------|
|
|
125
|
+
| `apps/api/services/auth.py` | 14 | 2 days ago |
|
|
126
|
+
| `apps/web/app/(dashboard)/page.tsx` | 11 | today |
|
|
127
|
+
|
|
128
|
+
## Active Work Area (last 5 commits)
|
|
129
|
+
- `apps/api/routes/billing.py` — new Stripe webhook handler
|
|
130
|
+
- `apps/web/components/PricingTable.tsx` — pricing UI overhaul
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 6. Embed Checkpoint Metadata
|
|
134
|
+
|
|
135
|
+
Add a `.codemap-meta.json` alongside the codemap:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"version": 1,
|
|
140
|
+
"generated_at": "2026-03-28T12:00:00Z",
|
|
141
|
+
"checkpoint": "post-merge main",
|
|
142
|
+
"file_count": 247,
|
|
143
|
+
"module_count": 18,
|
|
144
|
+
"git_sha": "a1b2c3d",
|
|
145
|
+
"hot_files_window_days": 30
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This lets the agent decide whether the codemap is stale (compare `git_sha` to `HEAD`).
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Checkpoint Triggers
|
|
154
|
+
|
|
155
|
+
Regenerate the codemap when:
|
|
156
|
+
|
|
157
|
+
| Trigger | When | Command |
|
|
158
|
+
|---------|------|---------|
|
|
159
|
+
| **Session start** | Agent begins a new conversation | Auto-check: if `.codemap.md` is stale or missing, regenerate |
|
|
160
|
+
| **Post-merge** | After merging a PR or rebasing | Regenerate to reflect new files and structure |
|
|
161
|
+
| **Post-refactor** | After moving/renaming files or directories | Regenerate to update paths and dependency flow |
|
|
162
|
+
| **On demand** | User requests `/codemap` | Full regeneration |
|
|
163
|
+
| **Pre-PR** | Before opening a pull request | Update hot files and active work area sections |
|
|
164
|
+
| **Staleness threshold** | `.codemap-meta.json` `git_sha` != current `HEAD` and > 10 commits behind | Auto-suggest regeneration |
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Edge Cases
|
|
169
|
+
|
|
170
|
+
1. **Monorepo with 500+ packages**: Do not map every file. Generate a top-level codemap with package summaries, then generate per-package codemaps (`packages/auth/.codemap.md`) only for packages the agent is actively working in. Use `--scope <package>` to limit scope.
|
|
171
|
+
|
|
172
|
+
2. **Generated code directories** (Prisma client, protobuf, OpenAPI): Mark entire directories as `[generated — do not edit]` in the directory map. Do not analyze individual files or exports. Note the generator config file (e.g., `schema.prisma`, `proto/*.proto`) as the real source of truth.
|
|
173
|
+
|
|
174
|
+
3. **Rapidly changing codebase** (10+ commits/day to same area): Set `hot_files_window_days` to 7 instead of 30 to keep the hot files section relevant. Consider running codemap generation as a post-commit hook or CI step.
|
|
175
|
+
|
|
176
|
+
4. **No git history** (fresh clone, shallow clone, or non-git project): Skip hot files and active work area sections. Use file modification timestamps (`stat`) as a fallback for recency. Note the limitation in the codemap header.
|
|
177
|
+
|
|
178
|
+
5. **Very large files** (> 1000 lines): Do not attempt to list all exports. Instead, note the file as `[large — 1,247 lines]` and list only the top 5 most-imported exports (determine via grep for import/require statements across the codebase).
|
|
179
|
+
|
|
180
|
+
6. **Polyglot repos** (e.g., Python backend + TypeScript frontend + Go CLI): Generate separate module map sections per language/runtime. Cross-language dependencies (e.g., frontend calling backend API) go in the Dependency Flow section as `[HTTP]` or `[gRPC]` edges, not direct import arrows.
|
|
181
|
+
|
|
182
|
+
7. **Codemap conflicts on merge**: `.codemap.md` will frequently conflict in merge scenarios since it changes with every checkpoint. Add `.codemap.md` and `.codemap-meta.json` to `.gitattributes` with `merge=ours` strategy, or add to `.gitignore` and generate locally. Recommend: do not commit the codemap; generate it on session start.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Output Format
|
|
187
|
+
|
|
188
|
+
The primary output is `.codemap.md` (see Section 5 for template). Print a summary:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
Codemap generated: .codemap.md
|
|
192
|
+
Files scanned: 247 | Modules: 18 | Entry points: 3 | Hot files: 12
|
|
193
|
+
Git SHA: a1b2c3d | Checkpoint: session-start
|
|
194
|
+
```
|