Ghost Catalog Skill
Manage semantic file headers and maintain the Ghost Catalog database for any workspace.
Header Format (SOM File ID)
Every cataloged file gets a semantic header in the first 20 lines:
# file_id: SOM-XXX-NNNN-vX.X.X
# name: filename.ext
# description: What this file does
# project_id: PROJECT-NAME
# category: script | doc | config | schema | component | test | data | style
# tags: [tag1, tag2, tag3]
# created: YYYY-MM-DD
# modified: YYYY-MM-DD
# version: X.X.X
# agent_id: AGENT-DROID-001
Comment style adapts to file type:
- Python/Shell/YAML/TOML:
# prefix
- JavaScript/TypeScript/Go/Rust/C:
// prefix inside /* ... */ block
- HTML/XML:
<!-- ... --> block
- Markdown:
<!-- ... --> HTML comment block
- CSS:
/* ... */ block
- SQL:
-- prefix
File ID Schema: SOM-XXX-NNNN-vX.X.X
| Segment |
Meaning |
Examples |
SOM |
Somacosf namespace (constant) |
SOM |
XXX |
3-letter category code |
SCR (script), DOC (doc), CFG (config), SCH (schema), CMP (component), TST (test), DAT (data), STY (style), LIB (library), API (api route), UTL (utility), HKS (hooks) |
NNNN |
4-digit sequential number |
0001, 0042, 0338 |
vX.X.X |
Semantic version |
v1.0.0, v2.1.3 |
Category Codes
| Code |
Category |
File Types |
SCR |
Script |
.py, .sh, .ps1, .bat |
DOC |
Document |
.md, .txt, .rst |
CFG |
Config |
.json, .yaml, .yml, .toml, .env, .ini |
SCH |
Schema |
.prisma, .graphql, .sql |
CMP |
Component |
.tsx, .jsx, .vue, .svelte |
TST |
Test |
*.test.*, *.spec.* |
DAT |
Data |
.csv, .json (data files), .db |
STY |
Style |
.css, .scss, .less |
LIB |
Library |
.ts, .js (lib modules) |
API |
API Route |
route.ts, route.js (Next.js API routes) |
UTL |
Utility |
Helper/utility modules |
HKS |
Hooks |
React hooks, git hooks |
Catalog Database
The catalog lives at data/ghost-catalog.db (SQLite). Schema:
CREATE TABLE IF NOT EXISTS file_catalog (
file_id TEXT PRIMARY KEY,
name TEXT NOT NULL,
description TEXT,
path TEXT NOT NULL,
project_id TEXT,
category TEXT,
version TEXT,
created TEXT,
modified TEXT,
agent_id TEXT,
execution TEXT,
checksum TEXT,
last_synced TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS file_tags (
file_id TEXT,
tag TEXT,
PRIMARY KEY (file_id, tag),
FOREIGN KEY (file_id) REFERENCES file_catalog(file_id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS agent_registry (
id TEXT PRIMARY KEY,
name TEXT,
model TEXT,
first_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_active TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_category ON file_catalog(category);
CREATE INDEX IF NOT EXISTS idx_project ON file_catalog(project_id);
CREATE INDEX IF NOT EXISTS idx_agent ON file_catalog(agent_id);
CREATE INDEX IF NOT EXISTS idx_tags ON file_tags(tag);
Commands
When the user invokes /ghost-catalog, determine which operation to perform based on their request. Default to scan if no specific command is given.
1. scan (default)
Scan the workspace for all source files. For each file:
- Check if it already has a SOM header (look for
file_id: SOM- in first 20 lines)
- If header exists: parse and validate it, update the catalog DB
- If no header: report it as untagged
Output a summary table:
Scanned: 150 files
Tagged: 42 files (28%)
Untagged: 108 files
Errors: 0
Ignore system (layered, merged at scan time):
.ghost_ignore (primary) -- Ghost Catalog's own ignore file, lives at project root. Follows .gitignore syntax. This is the canonical source of what to skip.
.gitignore (inherited) -- automatically merged; anything git ignores, Ghost Catalog ignores too.
- Hardcoded fallbacks -- if neither file exists, use:
.git/, node_modules/, .next/, .vercel/, __pycache__/, .venv/, dist/, build/, .factory/
When scanning, parse .ghost_ignore and .gitignore into a combined exclusion set. Only scan files that survive both filters. The goal: catalog project files only -- no dependencies, no build artifacts, no binaries, no secrets, no lock files.
2. tag <path|pattern>
Apply a Ghost Catalog header to one or more files:
- Read the file content
- Determine the category from file extension and location
- Query the catalog DB for the next available sequence number in that category
- Generate the header with appropriate comment syntax
- Prepend the header to the file (preserve existing content)
- Insert into the catalog DB
When tagging multiple files, show a preview table first and ask for confirmation before applying.
3. validate
Check all tagged files for header compliance:
- Required fields present:
file_id, name, description, category, version, created, modified
- File ID format valid:
SOM-XXX-NNNN-vX.X.X
- Version in file_id matches version field
- Filename in header matches actual filename
- No duplicate file IDs
Output a validation report with pass/warn/fail for each file.
4. search <query>
Search the catalog by any field:
search proxy - fuzzy match on name/description
search --category script - filter by category
search --tag opentelemetry - filter by tag
search --agent AGENT-CLAUDE-002 - filter by agent
Display results as a formatted table with file_id, name, category, and path.
5. info <file_id>
Show detailed metadata for a specific file from the catalog DB.
6. stats
Show catalog statistics:
- Total files, tagged vs untagged
- Breakdown by category
- Top tags
- Agent activity
- Last sync time
7. report
Generate a full compliance report in markdown format, saved to docs/ghost-catalog-report.md.
Implementation Notes
- Use Python 3 with
sqlite3 stdlib for database operations
- For scanning, use the Glob and Read tools rather than spawning processes
- When generating headers, always check what comment style the file uses
- Sequence numbers are global per category (not per project)
- The catalog DB should be created at
data/ghost-catalog.db if it doesn't exist
- Always use
AGENT-DROID-001 as the agent_id when this skill applies headers
- Version starts at
v1.0.0 for new files
modified date is always today's date when applying or updating headers
created date is preserved if already set, otherwise today's date
Verification
After any write operation (tag, validate --fix), re-read the modified files to confirm headers were applied correctly. Report any failures.
Auto-Invocation Guidance
This skill should be considered when:
- The user asks about file organization, cataloging, or headers
- A scan reveals many untagged files and the user wants to fix compliance
- The user creates new files and wants them cataloged
- The user asks "what files are in this project" or "show me the catalog"
1---
2name: ghost-catalog
3description: >-
4 Scan, tag, validate, and catalog files using the Ghost Catalog semantic file header system (SOM-XXX-NNNN-vX.X.X).
5 Use when: discovering untagged files, onboarding to a new codebase, maintaining catalog compliance,
6 searching for files by category/tag/agent, or generating compliance reports.
7 Operates on the local file system with a SQLite catalog database.
8user-invocable: true
9disable-model-invocation: false
10metadata:
11 source: https://skillmd.com/skills/modbender/ghost-catalog
12---
13
14# Ghost Catalog Skill
15
16Manage semantic file headers and maintain the Ghost Catalog database for any workspace.
17
18## Header Format (SOM File ID)
19
20Every cataloged file gets a semantic header in the first 20 lines:
21
22```
23# file_id: SOM-XXX-NNNN-vX.X.X
24# name: filename.ext
25# description: What this file does
26# project_id: PROJECT-NAME
27# category: script | doc | config | schema | component | test | data | style
28# tags: [tag1, tag2, tag3]
29# created: YYYY-MM-DD
30# modified: YYYY-MM-DD
31# version: X.X.X
32# agent_id: AGENT-DROID-001
33```
34
35Comment style adapts to file type:
36- Python/Shell/YAML/TOML: `#` prefix
37- JavaScript/TypeScript/Go/Rust/C: `//` prefix inside `/* ... */` block
38- HTML/XML: `<!-- ... -->` block
39- Markdown: `<!-- ... -->` HTML comment block
40- CSS: `/* ... */` block
41- SQL: `--` prefix
42
43### File ID Schema: `SOM-XXX-NNNN-vX.X.X`
44
45| Segment | Meaning | Examples |
46|---------|---------|----------|
47| `SOM` | Somacosf namespace (constant) | `SOM` |
48| `XXX` | 3-letter category code | `SCR` (script), `DOC` (doc), `CFG` (config), `SCH` (schema), `CMP` (component), `TST` (test), `DAT` (data), `STY` (style), `LIB` (library), `API` (api route), `UTL` (utility), `HKS` (hooks) |
49| `NNNN` | 4-digit sequential number | `0001`, `0042`, `0338` |
50| `vX.X.X` | Semantic version | `v1.0.0`, `v2.1.3` |
51
52### Category Codes
53
54| Code | Category | File Types |
55|------|----------|------------|
56| `SCR` | Script | `.py`, `.sh`, `.ps1`, `.bat` |
57| `DOC` | Document | `.md`, `.txt`, `.rst` |
58| `CFG` | Config | `.json`, `.yaml`, `.yml`, `.toml`, `.env`, `.ini` |
59| `SCH` | Schema | `.prisma`, `.graphql`, `.sql` |
60| `CMP` | Component | `.tsx`, `.jsx`, `.vue`, `.svelte` |
61| `TST` | Test | `*.test.*`, `*.spec.*` |
62| `DAT` | Data | `.csv`, `.json` (data files), `.db` |
63| `STY` | Style | `.css`, `.scss`, `.less` |
64| `LIB` | Library | `.ts`, `.js` (lib modules) |
65| `API` | API Route | `route.ts`, `route.js` (Next.js API routes) |
66| `UTL` | Utility | Helper/utility modules |
67| `HKS` | Hooks | React hooks, git hooks |
68
69## Catalog Database
70
71The catalog lives at `data/ghost-catalog.db` (SQLite). Schema:
72
73```sql
74CREATE TABLE IF NOT EXISTS file_catalog (
75 file_id TEXT PRIMARY KEY,
76 name TEXT NOT NULL,
77 description TEXT,
78 path TEXT NOT NULL,
79 project_id TEXT,
80 category TEXT,
81 version TEXT,
82 created TEXT,
83 modified TEXT,
84 agent_id TEXT,
85 execution TEXT,
86 checksum TEXT,
87 last_synced TIMESTAMP DEFAULT CURRENT_TIMESTAMP
88);
89
90CREATE TABLE IF NOT EXISTS file_tags (
91 file_id TEXT,
92 tag TEXT,
93 PRIMARY KEY (file_id, tag),
94 FOREIGN KEY (file_id) REFERENCES file_catalog(file_id) ON DELETE CASCADE
95);
96
97CREATE TABLE IF NOT EXISTS agent_registry (
98 id TEXT PRIMARY KEY,
99 name TEXT,
100 model TEXT,
101 first_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
102 last_active TIMESTAMP
103);
104
105CREATE INDEX IF NOT EXISTS idx_category ON file_catalog(category);
106CREATE INDEX IF NOT EXISTS idx_project ON file_catalog(project_id);
107CREATE INDEX IF NOT EXISTS idx_agent ON file_catalog(agent_id);
108CREATE INDEX IF NOT EXISTS idx_tags ON file_tags(tag);
109```
110
111## Commands
112
113When the user invokes `/ghost-catalog`, determine which operation to perform based on their request. Default to `scan` if no specific command is given.
114
115### 1. `scan` (default)
116
117Scan the workspace for all source files. For each file:
1181. Check if it already has a SOM header (look for `file_id: SOM-` in first 20 lines)
1192. If header exists: parse and validate it, update the catalog DB
1203. If no header: report it as untagged
121
122Output a summary table:
123```
124Scanned: 150 files
125Tagged: 42 files (28%)
126Untagged: 108 files
127Errors: 0
128```
129
130**Ignore system** (layered, merged at scan time):
131
1321. `.ghost_ignore` (primary) -- Ghost Catalog's own ignore file, lives at project root. Follows `.gitignore` syntax. This is the canonical source of what to skip.
1332. `.gitignore` (inherited) -- automatically merged; anything git ignores, Ghost Catalog ignores too.
1343. Hardcoded fallbacks -- if neither file exists, use: `.git/`, `node_modules/`, `.next/`, `.vercel/`, `__pycache__/`, `.venv/`, `dist/`, `build/`, `.factory/`
135
136When scanning, parse `.ghost_ignore` and `.gitignore` into a combined exclusion set. Only scan files that survive both filters. The goal: **catalog project files only** -- no dependencies, no build artifacts, no binaries, no secrets, no lock files.
137
138### 2. `tag <path|pattern>`
139
140Apply a Ghost Catalog header to one or more files:
141
1421. Read the file content
1432. Determine the category from file extension and location
1443. Query the catalog DB for the next available sequence number in that category
1454. Generate the header with appropriate comment syntax
1465. Prepend the header to the file (preserve existing content)
1476. Insert into the catalog DB
148
149When tagging multiple files, show a preview table first and ask for confirmation before applying.
150
151### 3. `validate`
152
153Check all tagged files for header compliance:
154- Required fields present: `file_id`, `name`, `description`, `category`, `version`, `created`, `modified`
155- File ID format valid: `SOM-XXX-NNNN-vX.X.X`
156- Version in file_id matches version field
157- Filename in header matches actual filename
158- No duplicate file IDs
159
160Output a validation report with pass/warn/fail for each file.
161
162### 4. `search <query>`
163
164Search the catalog by any field:
165- `search proxy` - fuzzy match on name/description
166- `search --category script` - filter by category
167- `search --tag opentelemetry` - filter by tag
168- `search --agent AGENT-CLAUDE-002` - filter by agent
169
170Display results as a formatted table with file_id, name, category, and path.
171
172### 5. `info <file_id>`
173
174Show detailed metadata for a specific file from the catalog DB.
175
176### 6. `stats`
177
178Show catalog statistics:
179- Total files, tagged vs untagged
180- Breakdown by category
181- Top tags
182- Agent activity
183- Last sync time
184
185### 7. `report`
186
187Generate a full compliance report in markdown format, saved to `docs/ghost-catalog-report.md`.
188
189## Implementation Notes
190
191- Use Python 3 with `sqlite3` stdlib for database operations
192- For scanning, use the Glob and Read tools rather than spawning processes
193- When generating headers, always check what comment style the file uses
194- Sequence numbers are global per category (not per project)
195- The catalog DB should be created at `data/ghost-catalog.db` if it doesn't exist
196- Always use `AGENT-DROID-001` as the agent_id when this skill applies headers
197- Version starts at `v1.0.0` for new files
198- `modified` date is always today's date when applying or updating headers
199- `created` date is preserved if already set, otherwise today's date
200
201## Verification
202
203After any write operation (tag, validate --fix), re-read the modified files to confirm headers were applied correctly. Report any failures.
204
205## Auto-Invocation Guidance
206
207This skill should be considered when:
208- The user asks about file organization, cataloging, or headers
209- A scan reveals many untagged files and the user wants to fix compliance
210- The user creates new files and wants them cataloged
211- The user asks "what files are in this project" or "show me the catalog"