Update the graft (feature flag) inventory when flags are added or removed...
Activate this skill when:
| File | Purpose |
|---|---|
.github/graft-inventory.json |
Source of truth for graft counts and metadata |
libs/engine/migrations/*.sql |
Migration files that define grafts |
libs/engine/src/lib/platform/feature-flags/flags.ts |
Type definitions (KnownFlagId) |
docs/guides/adding-grafts-and-flags.md |
Developer guide (grafts = Grove term for feature flags) |
The inventory tracks grafts with full metadata:
{
"grafts": {
"total": 10,
"breakdown": {
"platform": 8,
"greenhouse": 2
},
"byType": {
"boolean": 9,
"number": 1
}
},
"flags": [
{
"id": "fireside_mode",
"name": "Fireside Mode",
"type": "boolean",
"greenhouseOnly": true,
"migration": "040_fireside_scribe_grafts.sql",
"description": "AI-assisted writing prompts"
}
]
}
# Extract all flag IDs from migration INSERT statements
grep -hoP "INSERT OR IGNORE INTO feature_flags.*?VALUES\s*\(\s*'\K[a-z_]+" libs/engine/migrations/*.sql | sort -u
# Get actual flags from production database
npx wrangler d1 execute grove-engine-db --remote --command="SELECT id, name, flag_type, greenhouse_only, enabled FROM feature_flags ORDER BY id;"
# Read current inventory
cat .github/graft-inventory.json | jq '.flags[].id' | sort
Look for:
Edit .github/graft-inventory.json:
Update counts:
"grafts": {
"total": <new count>,
"breakdown": {
"platform": <non-greenhouse count>,
"greenhouse": <greenhouse_only count>
}
}
Add/remove flag entries:
"flags": [
{
"id": "new_flag_id",
"name": "Human Readable Name",
"type": "boolean",
"greenhouseOnly": false,
"migration": "XXX_migration_name.sql",
"description": "What this flag controls"
}
]
Update metadata:
"lastUpdated": "YYYY-MM-DD",
"lastAuditedBy": "claude/<context>"
Edit libs/engine/src/lib/platform/feature-flags/flags.ts:
export type KnownFlagId =
| "fireside_mode"
| "scribe_mode"
| "meadow_access"
| "jxl_encoding"
| "jxl_kill_switch"
| "new_flag_id"; // Add new flag
git add .github/graft-inventory.json libs/engine/src/lib/platform/feature-flags/flags.ts
git commit -m "docs: update graft inventory
- Add <flag_id> to inventory
- Update total: X -> Y
- Update KnownFlagId type"
# Count grafts in migrations
grep -c "INSERT OR IGNORE INTO feature_flags" libs/engine/migrations/*.sql | awk -F: '{sum+=$2} END {print sum}'
# List all flag IDs
grep -hoP "INSERT OR IGNORE INTO feature_flags.*?VALUES\s*\(\s*'\K[a-z_]+" libs/engine/migrations/*.sql | sort -u
# Count greenhouse-only grafts
npx wrangler d1 execute grove-engine-db --remote --command="SELECT COUNT(*) FROM feature_flags WHERE greenhouse_only = 1;"
# Full flag details from production
npx wrangler d1 execute grove-engine-db --remote --command="SELECT * FROM feature_flags ORDER BY id;"
# Check which migrations haven't been applied
# Compare migration file flag IDs vs production D1 flag IDs
When adding a new graft:
libs/engine/migrations/XXX_name.sqlnpx wrangler d1 execute grove-engine-db --remote --file=...KnownFlagId type in flags.ts.github/graft-inventory.json flags arraylastUpdated and lastAuditedByAfter updating, verify production matches:
# Expected count
jq '.grafts.total' .github/graft-inventory.json
# Actual count in production
npx wrangler d1 execute grove-engine-db --remote --command="SELECT COUNT(*) as count FROM feature_flags;"
If they don't match, migrations may need to be applied:
# Apply a specific migration
npx wrangler d1 execute grove-engine-db --remote --file=libs/engine/migrations/XXX_name.sql
The .github/workflows/graft-inventory.yml workflow:
libs/engine/migrations/*.sqllibs/engine/src/lib/feature-flags/**When CI fails, run this skill to fix the mismatch.
Before finishing:
totalflags arrayKnownFlagId type includes all flag IDslastUpdated date is todaytotal = platform + greenhouse