Tutorial

From indigoai-us/hq-core · View interactive version

Tutorial is an AI agent skill from the GitHub repository indigoai-us/hq-core. Run hands-on HQ workflow lessons.

How to use this skill

Skill file

Tutorial — Learn HQ by Doing

Interactive, modular lessons teaching HQ principles through hands-on exercises against the user's real HQ. Each topic follows a 5-phase flow: Concept, Show, Exercise, Verify, Takeaway. Content sources include Build Your Own AGI (where available) and the core/knowledge/public/getting-started/ docs — the book is a supporting reference, not a prerequisite.

Ordering rationale: Lead with principles and daily workflow — most users won't run /run-project orchestration until they've lived in HQ. Ralph-loop orchestration (Topic 8) and worker authoring (Topic 9) come last, where users have enough context to appreciate them.

Input: $ARGUMENTS — optional topic slug. If empty, show topic menu.

Step 0: Parse Input

If $ARGUMENTS is non-empty, match against topic slugs:

| Input | Topic |

|-------|-------|

| cloud, team, collaboration, hq-sync, hq-share, hq-secrets, hq-deploy, hq-bug | 0. Cloud & Team Collaboration |

| principles, ralph-principles, mindset | 1. Ralph Principles |

| hq, workflow, daily, folder, folders | 2. Working with HQ |

| knowledge | 3. Knowledge Architecture |

| session-hygiene, hygiene, sessions | 4. Session Hygiene |

| context-management, context, tokens | 5. Context Management |

| projects, prd, prds | 6. Projects |

| scaling, parallel, multi-session | 7. Scaling |

| ralph-loop, ralph, loop, run-project | 8. The Ralph Loop (Orchestration) |

| workers, worker | 9. Workers |

If matched: skip to Step 2 with that topic.

If no match: show error + topic menu (Step 1).

If empty: proceed to Step 1.

Step 1: Topic Menu

Maturity Detection

Silently assess HQ state:

  1. Check core/workers/registry.yaml — count company-specific workers (type: company)
  2. Check for any prd.json files in companies/*/projects/ or personal/projects/
  3. Count companies in companies/manifest.yaml
  4. Cloud / team detection — silently run:

```bash

grep -l 'cloud' companies/*/manifest.yaml 2>/dev/null | head -1

grep -iE 'cloud_backed|cloud_uid|hq[-_]?pro|team' companies/manifest.yaml 2>/dev/null | head -3

```

Either signal hit → flag as CLOUD.

Classify:

Present Menu

Menu structure adapts to the CLOUD flag:

HQ Tutorial
───────────
Learn HQ principles from "Build Your Own AGI" — interactive lessons
with hands-on exercises using your actual HQ.

  Cloud & Team Collaboration                       [shown only if CLOUD detected]
  0. Cloud & Team           — hq-sync, hq-share, hq-secrets, hq-deploy, hq-bug

  Foundations
  1. Ralph Principles      — Plan mode, fresh context, back pressure (mindset)
  2. Working with HQ       — Daily workflow: /startwork → work → /handoff

  Daily Practice
  3. Knowledge             — Hot vs cold channels, qmd search, gardens
  4. Session Hygiene       — /checkpoint, /handoff, thread files
  5. Context Management    — Token optimization, Context Diet, advisories
  6. Projects              — PRDs, /idea → /prd, acceptance criteria
  7. Scaling               — Parallel sessions, company isolation

  Advanced
  8. The Ralph Loop        — /run-project orchestration (principles in action)
  9. Workers               — /newworker, worker.yaml, /learn training

  Recommended for you: {see below}

  Full book: {your-book-site}

Recommendation logic:

Wait for user selection via AskUserQuestion. Route to Step 2 with chosen topic.

Step 2: Run Lesson

Execute the 5-phase lesson flow for the selected topic. Each phase is described below.

Phase 1: Concept (synthesize, don't paste)

  1. Attempt to read book chapter. Check if the book exists at personal/knowledge/curriculum/book/handbook.md; on not-yet-migrated installations, fall back to the legacy repos/private/knowledge-curriculum/book/handbook.md (reading it is fine — note that hq reindex migrates it). If found, read ONLY the line range for this topic's chapter (see Topic Registry below). If neither exists, use fallback sources.
  2. Read the HQ reference file(s) listed in the topic's hq_refs field.
  3. Synthesize a 200-300 word explanation of the core concept in your own words. Do NOT paste paragraphs from the book.
  4. Surface the key quote defined for this topic — attribute it to the book.
  5. Link to the book: "Full chapter: Ch {N} in Build Your Own AGI — {your-book-site}"

Phase 2: Show (inspect user's HQ)

Run the read-only inspection commands defined in the topic's show field. Annotate what you find with how it connects to the concept just explained.

Two paths:

Phase 3: Exercise (hands-on)

Present the exercise defined in the topic's exercise field.

Exercise tiers:

Phase 4: Verify

For Tier 1 exercises: present what the exercise revealed and ask the user a comprehension question.

For Tier 2 exercises: check for expected side effects (new files, updated state) or ask "What did you see?"

Phase 5: Takeaway

  1. State the one principle from this topic (defined in takeaway field).
  2. Reference existing docs: "Quick reference: core/knowledge/public/getting-started/cheatsheet.md"
  3. Suggest next topic: "Next: try /tutorial {next_topic} or pick another from /tutorial"
  4. Book link: "Deeper dive: Ch {N} in Build Your Own AGI — {your-book-site}"

Topic Registry

Topic 0: cloud — Cloud & Team Collaboration (CLOUD-gated)

→ /hq-sync (or just tell Claude "sync HQ")

Reconciles every cloud-backed company in both directions. Runs the same engine as the HQ Desktop App "Sync" button. Use it at the start of a session if you switched machines, or at the end if you want a teammate to see what you just did. If there are conflicts (you and the cloud changed the same file), HQ surfaces them — /resolve-conflicts walks you through each one.

→ /hq-share <path>

Generates a one-time link, opens a picker in your browser, and lets you grant any teammates you want (one or many at once). The link is live for 15 minutes and only works once — that's by design, so a leaked link can't be reused. After you've granted access, the teammates have it permanently; the link is just the handoff.

→ /hq-secrets

Stores credentials in the cloud per company. Once stored, any teammate with access can use them in their sessions without ever seeing the raw value — Claude fetches them at runtime and never prints them in chat. Best for: Shopify tokens, Stripe keys, database URLs, anything you'd otherwise paste into a .env file. If a credential needs a human to log in (OAuth, 2FA), HQ mints a link to send instead.

→ /deploy

Ships whatever you just made — a generated report, a brief, a static page — to the hq-deploy host and returns a shareable URL. Optional password protection if it's sensitive. Use this when chat-pasting a long doc would be awkward, or when you want a single link that teammates can bookmark.

→ /hq-bug

Files a report directly to the HQ team. Auto-attaches your session context (which command was running, what failed, what directory you were in) so you don't have to write a repro. Use it freely — friction here is the difference between a fixed bug and a forgotten one.

1. Read companies/manifest.yaml → name the user's cloud-backed companies (the ones with cloud_uid: or similar markers)

2. Ask the user: "Of the 5, which scenario actually fits something you want to do today? Pick one and I'll walk you through it." Map their answer to the command and explain the first step

Topic 1: principles — Ralph Principles (NEW)

1. Read one past thread file from workspace/threads/ (or the bundled sample if fresh)

2. Ask the user: "Ralph has three principles. Looking at this session, can you name them and point to one moment in the thread that embodies each?" (Answer: plan mode, fresh context per task, back pressure/verification)

Topic 2: hq — Working with HQ (NEW)

1. From companies/manifest.yaml, pick a company the user works in. Locate one file in each of: companies/{co}/settings/, companies/{co}/knowledge/, companies/{co}/workers/. Show the user what each holds

2. Ask: "If you opened HQ tomorrow morning and wanted to resume yesterday's work, what's the first command you'd run and what file would it read?" (Answer: /startwork reads workspace/threads/handoff.json)

Topic 3: knowledge

1. Pick a keyword relevant to the user's work (ask them for one via AskUserQuestion)

2. Run qmd search "{keyword}" --json -n 5 (BM25 keyword search)

3. Run qmd vsearch "{keyword}" --json -n 5 (semantic/vector search)

4. Compare results — explain: keyword search finds exact terms; semantic search finds related concepts

Topic 4: session-hygiene

1. Tell the user: "Run /checkpoint right now to see session saving in action."

2. Wait for user to run it

3. After they confirm, read the most recent thread file in workspace/threads/ and walk through what it captured

Topic 5: context-management

1. Read the Context Diet rules in CLAUDE.md — count the "do NOT" rules

2. Run wc -l .claude/CLAUDE.md — show the instruction file size as an example of keeping context tight

3. Examine: "Every file you Read costs tokens. What does the Context Diet section tell you NOT to read at session start?" (Answer: INDEX.md, agents files, company knowledge — unless the task requires it)

Topic 6: projects

1. If a prd.json exists: read it and ask "How many stories are in this project? How many have passed verification?" Show how passes: true/false creates back pressure

2. If none: explain the /idea → /brainstorm → /prd → /run-project pipeline. Suggest: "Try /idea to capture something small on your board."

Topic 7: scaling

1. Read companies/manifest.yaml and count: companies, total repos across all companies, total workers

2. Read the Company Isolation hard rules from CLAUDE.md (the "NEVER" list)

3. Ask: "If you were running sessions for two different companies simultaneously, what prevents you from accidentally using Company A's credentials in Company B's session?" (Answer: manifest-based credential routing, company-scoped policies, cross-company hooks)

Topic 8: ralph-loop — The Ralph Loop (Orchestration) *(rescoped)*

1. Run qmd search "run-project passes acceptance" --json -n 5 — find orchestrator references

2. Read one prd.json with a story that has passes: false (if any). Identify the acceptance criteria that would flip it to passes: true

3. Ask: "In an 8-hour autonomous overnight run, what prevents the orchestrator from marking a failing task as done and moving on?" (Answer: acceptance criteria + passes field + sub-agent verification step)

Topic 9: workers

1. Read a worker.yaml and identify the four components: identity (name, role), context (knowledge paths), skills (what it can do), permissions (tool access)

2. Suggest: "After this tutorial, try /newworker to create your first domain-specific worker. Use /learn to teach it as you go."


Book Reference Protocol

The book at personal/knowledge/curriculum/book/handbook.md is the source material (legacy installations may still have it at repos/private/knowledge-curriculum/book/handbook.md until hq reindex migrates it — read whichever exists).

Rules:

  1. Read ONLY the line range mapped to the current topic's chapter — never the full book
  2. Synthesize in your own words — never paste paragraphs from the book
  3. Surface exactly ONE key quote per topic (defined in Topic Registry) — attribute to the book
  4. End every lesson with: "Full chapter: Ch {N} in Build Your Own AGI — {your-book-site}"
  5. If the book file does not exist (starter-kit users without the private repo), use the fallback files listed per topic + link to {your-book-site} for the full content

Topic Ordering Discipline

Topics 1 and 8 both draw from Ch 3 but split cleanly:

| Topic | Scope | Do teach | Don't teach |

|-------|-------|----------|-------------|

| 1. principles | Mindset | plan mode, fresh context, back pressure (as concepts) | /run-project, sub-agents, file locking |

| 8. ralph-loop | Mechanics | /run-project, orchestrator config, passes field, file locks | plan mode theory (assume known from Topic 1) |

If a user asks an orchestration question during Topic 1, route them: "That's Topic 8 — finish principles first."

If a user asks a principles question during Topic 8, say: "Refresher: Topic 1 covers the mindset" but continue with mechanics.

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.