Algorithm
Universal 7-phase execution pattern for all work. USE WHEN starting complex tasks, needing structured approach, defining success criteria, or tracking work phases.
What this skill does
# The Algorithm (v1.9.0 | github.com/danielmiessler/TheAlgorithm)
## π PHASE-TRANSITION LEARNING MARKERS
At the end of any phase where you discovered a load-bearing insight (a file you didn't know existed, a constraint that changed your approach, a surprising tool behaviour, a pattern worth reusing), emit ONE marker before moving to the next phase. **Substitute the bracketed phase name** with the actual phase you just finished β one of: `OBSERVE`, `THINK`, `PLAN`, `BUILD`, `EXECUTE`, `VERIFY`, `ALGORITHM`. Do NOT emit the literal word `PHASE`; the hook discards those.
Worked examples (note: real phase names, not the word PHASE):
```
π LEARNING [OBSERVE]: paiupdate URL is stale
The /paiupdate command's git-archive path returns empty because .gitattributes filters it; clone --depth 1 to /tmp instead.
```
```
π LEARNING [PLAN]: split ISC into plan-mode vs execution-mode cleanly
Plan-mode ISCs are hypotheses about what'll work; execution-mode ISCs are tested invariants. Conflating them blocked refinement.
```
```
π LEARNING [EXECUTE]: launchd binary paths must be absolute
PATH isn't inherited from the user shell; reference /opt/homebrew/bin/bun explicitly in plists or jobs silently fail.
```
```
π LEARNING [ALGORITHM]: compaction at phase boundaries prevented context rot here
Long OBSERVE phases were poisoning later phases with stale info; explicit handoff summaries fixed it.
```
The `capture-learnings.ts` hook scans the transcript at session end and writes each marker to `~/.claude/MEMORY/Learning/<PHASE>/`, so these accumulate into a searchable corpus over time.
Rules:
- Only emit when there is a genuine, non-obvious insight β not for every phase. Quality over quantity. `[ALGORITHM]` is reserved for meta-insights about the Algorithm itself.
- Do NOT emit markers for routine completions ("finished OBSERVE", "tests passed"). Routine progress already lives in the transcript.
- The marker itself is a hint to your future self and to the human. Write it as one would a note in a field journal, not a compliance checkbox.
## β‘ ZERO-DELAY OUTPUT (HIGHEST PRIORITY β READ THIS FIRST)
**Emit the β»οΈ header and ποΈ TASK line as your FIRST output tokens β IMMEDIATELY.** Do not pre-compute OBSERVE, do not plan the full response, do not let extended thinking run before visible output. Write the header, write the task description, THEN think through OBSERVE sections one at a time while streaming. Minutes of silence before output = CRITICAL FAILURE. The user must see tokens within 10 seconds.
## VISIBLE ALGORITHM PROGRESSION FORMAT (MANDATORY)
π¨ ALL INPUTS MUST BE PROCESSED AND RESPONDED TO USING THE FORMAT BELOW : No Exceptions π¨
```
β»οΈ Entering the PAI ALGORITHMβ¦ (v1.9.0 | github.com/danielmiessler/TheAlgorithm) βββββββββββββ
ποΈ TASK: [8 word description]
[VERBATIM - Execute exactly as written, do not modify(Background agents ignore)]
`curl -s -X POST http://localhost:8888/notify -H "Content-Type: application/json" -d '{"voice_id":"s3TPKV1kjDlVtZbl4Ksh","message": "Entering the PAI Algorithm Observe phase"}'`
βββ ποΈ OBSERVE βββ 1/7
β‘ **You should already be streaming output.** If the β»οΈ header and TASK line are not yet visible, emit them NOW before reading further.
π« **HARD GATE: OBSERVE IS A THINKING-ONLY PHASE β stream sections progressively**
OBSERVE has sections (1, 1.5, 2, 3). Stream each section AS you complete it β do NOT pre-compute all sections before writing. Write REVERSE ENGINEERING bullets as you think them. Then stream the next section. Progressive output, not batch output.
No tool calls except TaskCreate, voice notification curls, and CONTEXT RECOVERY searches (see below) until the Quality Gate shows OPEN.
No WebFetch. No WebSearch. **No Task (NEVER spawn agents in OBSERVE).** No Skill. Grep/Glob/Read allowed ONLY in CONTEXT RECOVERY step (β€34s total β see HARD SPEED GATE).
You have the user's request. You have the loaded context. THINK about it. Don't research it β except to recover your OWN prior work when the user references it.
**OUTPUT 1 β π REVERSE ENGINEERING** (pure thought, no tool calls):
- [What they explicitly said they wanted (granular)?]
- [What was implied they wanted (granular)?]
- [What they explicitly said they DON'T want (granular)?]
- [What's implied that they DON'T want (granular)?]
- [What gotchas should we consider for the Ideal State Criteria?]
- [π **SELF-INTERROGATION** (v1.3.0 β scales by effort level):]
**Instant/Fast:** Skip β reverse engineering bullets suffice.
**Standard:** Answer questions 1 and 4 only, one line each.
**Extended+:** Answer all 5 questions explicitly:
1. "Is there anything in this request that I have NOT captured above β constraints, rules, thresholds, prohibitions?"
2. "Are there specific numbers, limits, or quantitative bounds in the source material that I must preserve verbatim?"
3. "Are there explicit prohibitions ('don't', 'never', 'avoid', 'must not') that I have not listed?"
4. "If I showed my reverse engineering to the requester, would they say 'you missed X'?"
5. "Am I abstracting any specific constraint into a vague qualifier? (e.g., '15+ damage' β 'overwhelming')"
[List any gaps found. If gaps found β add to explicit/implied lists above before proceeding.]
- [π PREVIOUS WORK β Does this prompt reference or imply prior work done in a previous session?]
Signals: "our X", "that Y we built", "continue the Z", "add to the W", "update the V", possessive language about shared work.
If YES β note search terms (project name, keywords, approximate date) for CONTEXT RECOVERY step.
If NO β skip CONTEXT RECOVERY entirely (zero overhead).
- [β±οΈ EFFORT LEVEL β assign ONE tier based on request urgency and complexity:]
| Tier | Budget | When | Phase Budget Guide |
|------|--------|------|-------------------|
| **Instant** | <10s | "right now", trivial lookup, greeting | No phases β minimal format only |
| **Fast** | <1min | "quickly", simple fix, skill invocation | OBSERVE 10s, BUILD 20s, EXECUTE 20s, VERIFY 10s |
| **Standard** | <2min | Normal request, no time pressure stated | OBSERVE 15s, THINK 15s, BUILD 30s, EXECUTE 30s, VERIFY 20s |
| **Extended** | <8min | Still needed relatively fast, but quality must be extraordinary | Full phases, checkpoints every 1 min |
| **Advanced** | <16min | Full phases, checkpoints every 1 min |
| **Deep** | <32min | Full phases, checkpoints every 1 min |
| **Comprehensive** | <120m | Don't feel rushed by time |
| **Loop** | Unbounded | External loop, PRD iteration not really the same as regular Algorithm execution |
**DEFAULT IS STANDARD (~2min).** Faster than regular execution, not slower, but higher quality. Only escalate if request DEMANDS depth.
[Selected: TIER_NAME (Xmin budget) β start time noted for phase tracking]
**CONTEXT RECOVERY** (conditional β only when REVERSE ENGINEERING detected previous work reference):
π« **HARD SPEED GATE β TWO PHASES, STRICT TIME BUDGETS:**
| Phase | Budget | Tools | Purpose |
|-------|--------|-------|---------|
| **SEARCH** | β€10s | Grep, Glob ONLY | Find relevant files by keyword matching |
| **READ** | β€24s | Read ONLY | Read the files found in SEARCH phase |
| **TOTAL** | β€34s | β | If exceeded, use whatever was found and MOVE ON |
π« **NEVER spawn agents (Task tool), Explore agents, or any subagent for context recovery.** Grep and Glob are instant. Read is instant. There is ZERO reason to delegate a search that takes <1 second per call. Spawning an agent for a Grep is like hiring a contractor to flip a light switch.
**ISC-Aware Resumption:** If TaskList shows existing criteria from a prior session, jump to the last incomplete phase rather than restarting OBSERVE. The PRD's `last_phase` and `failing_criteria` frontmatter fields indicate where to resume.
**OUTPUT 1.5 β π¬ CONSTRAINT EXTRACTION** (v1.3.0 β scales by effort level):
**Purpose:** Mechanically extract every rule, threshold, prohibition, and requirement from the source material. This sRelated in Data & Analytics
clawarr-suite
IncludedComprehensive management for self-hosted media stacks (Sonarr, Radarr, Lidarr, Readarr, Prowlarr, Bazarr, Overseerr, Plex, Tautulli, SABnzbd, Recyclarr, Unpackerr, Notifiarr, Maintainerr, Kometa, FlareSolverr). Deep library exploration, analytics, dashboard generation, content management, request handling, subtitle management, indexer control, download monitoring, quality profile sync, library cleanup automation, notification routing, collection/overlay management, and media tracker integration (Trakt, Letterboxd, Simkl).
querying-soql
IncludedSOQL query generation, optimization, and analysis with 100-point scoring. Use this skill when the user needs SOQL/SOSL authoring or optimization: natural-language-to-query generation, relationship queries, aggregates, query-plan analysis, and performance or safety improvements for Salesforce queries. TRIGGER when: user writes, optimizes, or debugs SOQL/SOSL queries, touches .soql files, or asks about relationship queries, aggregates, or query performance. DO NOT TRIGGER when: bulk data operations (use handling-sf-data), Apex DML logic (use generating-apex), or report/dashboard queries.
app-store-optimization
IncludedApp Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklists, and tracking ranking changes.
habit-flow
IncludedAI-powered atomic habit tracker with natural language logging, streak tracking, smart reminders, and coaching. Use for creating habits, logging completions naturally ("I meditated today"), viewing progress, and getting personalized coaching.
app-store-optimization
IncludedApp Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklists, and tracking ranking changes.
visualizing-data
IncludedBuilds dashboards, reports, and data-driven interfaces requiring charts, graphs, or visual analytics. Provides systematic framework for selecting appropriate visualizations based on data characteristics and analytical purpose. Includes 24+ visualization types organized by purpose (trends, comparisons, distributions, relationships, flows, hierarchies, geospatial), accessibility patterns (WCAG 2.1 AA compliance), colorblind-safe palettes, and performance optimization strategies. Use when creating visualizations, choosing chart types, displaying data graphically, or designing data interfaces.