diff --git a/.continue/checks/feature-flag-audit-and-cleanup-agent.md b/.continue/checks/feature-flag-audit-and-cleanup-agent.md new file mode 100644 index 0000000..f687e69 --- /dev/null +++ b/.continue/checks/feature-flag-audit-and-cleanup-agent.md @@ -0,0 +1,177 @@ +--- +name: Feature Flag Audit and Cleanup Agent +tools: built_in, posthog/posthog-mcp +--- + +## Purpose + +Audit PostHog feature flags to identify unused, outdated, or problematic flags. Create GitHub issues for cleanup and optimization tasks. + +## Execution Steps + +### Phase 1: Flag Discovery + +1. Fetch all flags: `mcp__posthog__feature-flag-get-all` +2. Get flag details: `mcp__posthog__feature-flag-get-definition` +3. Check usage analytics: `mcp__posthog__query-run` +4. Get performance data: `mcp__posthog__insights-get-all` + +### Phase 2: Flag Classification + +| Category | Criteria | Priority | +| --- | --- | --- | +| **Ready for Removal** | 100% rollout for 90+ days, no A/B test pending | HIGH | +| **Stale Experimental** | Created 120+ days ago, rollout <50%, no recent changes | MEDIUM | +| **Complex Targeting** | 5+ targeting rules, nested logic, high maintenance | MEDIUM | +| **Performance Impact** | Correlated with slow loads, error increases | HIGH | +| **Cleanup Required** | Orphaned (no code refs), duplicate, deprecated | VARIES | + +### Phase 3: GitHub Issue Creation + +```bash +gh issue create \ + --title "🏁 Feature Flag [ACTION]: [flag_name]" \ + --body "[template]" \ + --label "technical-debt,feature-flag,cleanup,[priority]" + +``` + +## Triage Decision Tree + +``` +100% rollout for 90+ days? +├─ YES → Ready for Removal +└─ NO → Modified in last 120 days? + ├─ NO → Rollout <50%? → Stale Experimental + └─ YES → 5+ targeting rules? + ├─ YES → Complex Targeting + └─ NO → Performance issues? → Performance Impact + └─ No code refs? → Cleanup Required + +``` + +## GitHub Issue Template + +```markdown + + +## 🏁 Feature Flag [Category]: [flag_name] + +**Priority:** [HIGH/MEDIUM] +**Created:** [date] +**Last Modified:** [date] +**Current Rollout:** [X]% + +### Flag Configuration +```json +{ + "key": "[flag_name]", + "rollout_percentage": [X], + "targeting_rules": [count], + "active": [true/false] +} + +``` + +### Analysis + +[Why this flag needs attention] + +### Usage Stats + +- Evaluations (30 days): [X] +- Users affected: [X] +- Targeting rules: [X] + +### Recommended Action + +**Option:** [Remove / Simplify / Roll forward / Roll back] + +```bash +# Verification steps +grep -r "[flag_name]" src/ + +``` + +**Files to update:** `[file_paths]` + +### Checklist + +- [ ] Verify no active usage +- [ ] Update codebase +- [ ] Remove from PostHog +- [ ] Monitor for 48 hours + +--- +**Generated by:** Feature Flag Audit Agent +**Date:** [current_date] + +``` + +## Audit Summary Template + +```markdown + + +# 🏁 Feature Flag Audit - [Date] + +## Overview +- **Total Flags:** [X] +- **Needing Attention:** [Y] +- **Ready for Removal:** [A] +- **Stale:** [B] +- **Complex:** [C] + +## Priority Breakdown +🔴 HIGH: [X] flags +🟡 MEDIUM: [Y] flags + +## Top Actions +1. Remove `[flag]` - 100% for [X] days +2. Review `[flag]` - stale experiment +3. Simplify `[flag]` - [X] targeting rules + +## Metrics +- Flags 100% rolled out: [X] +- Flags >180 days old: [Y] +- Average targeting rules: [Z] + +--- +**Generated by:** Feature Flag Audit Agent + +``` + +## Commit Message Format + +``` +feat(flags): remove [flag_name] feature flag + +- 100% rolled out for [X] days +- Removed from [X] files +- References: #[issue_number] + +``` + +## PostHog MCP Tools + +| Tool | Purpose | +| --- | --- | +| `feature-flag-get-all` | List all flags | +| `feature-flag-get-definition` | Flag details | +| `query-run` | Usage analytics | +| `insights-get-all` | Performance data | + +## Required GitHub Labels + +`technical-debt`, `feature-flag`, `cleanup`, `high-priority`, `medium-priority`, `performance` + +## Schedule + +- **Weekly:** Quick audit of new flags + critical issues +- **Monthly:** Comprehensive audit of all flags + +## Success Metrics + +- Flag count reduction +- Average flag lifetime +- Technical debt reduction \ No newline at end of file