Gem Team Framework

repository·main·Indexed 41 days ago

https://github.com/mubaidr/gem-team

An engineering-focused framework that wraps AI coding agents in a disciplined delivery system. It utilizes intelligent model routing, structured planning, and specialized agent roles—such as Orchestrator, Planner, Implementer, and Reviewer—to turn ad-hoc AI interactions into a repeatable, high-quality engineering process. Compatible with AI tools including Copilot, Claude, Cursor, OpenCode, Codex, Gemini, and Windsurf.

Tokens
15.4K
Snippets
40
Records
81
Agent score
52%

What's inside Gem Team

  1. Overview of Gem Team capabilities

    main

    Gem Team transforms AI coding from single-prompt outputs into a coordinated engineering pipeline that plans, builds, reviews, and learns. It provides a workflow designed to enforce software engineering best practices through agents and skills.

    Key capabilities include:

    • Quality by default: Automatic TDD, acceptance checks, and risk-based reviews.
    • Smart & efficient: Scoped handoffs and high cache-hit rates to keep token costs proportional to new work.
    • Resumable plans: Uses persistent plan IDs and plan.yaml for MEDIUM/HIGH complexity work, allowing you to pause, resume, or extend tasks without losing context.
    • Failure classification: Automatically routes failures to the appropriate agent instead of simple retries.
    • Tool compatibility: Works with Copilot, Claude, Cursor, Codex, Gemini, or Windsurf.
    • Continuous learning: Converts stable patterns into reusable skills and uses confidence-gated memory.
  2. How the Gem Team Orchestrator works

    main

    The Orchestrator is the central coordinator of the Gem Team workflow (Phases 0-4). It does not execute specialist work directly; instead, it delegates tasks to agents defined in .apm/agents/ and manages the following:

    • Workflow Coordination: Delegates work, tracks state, and enforces verification gates.
    • Error Classification: Classifies failures into specific categories (e.g., retry, fixable, replan, flaky, regression, platform-specific, test-bug) to route them to the correct agent.
    • Context Propagation: Passes typed handoff outputs into handoff.relevant_context of dependent tasks so discoveries persist across agent instances.
    • Memory Management: Promotes stable research findings to repo memory and injects relevant memory into planning context.
    • Resilience: Applies relational invariant fallbacks to infer intent and fill safe defaults when agent outputs miss conditional fields, preventing valid work from being rejected.
  3. Understand the Gem Team Orchestrator Workflow

    main

    The Gem Team Orchestrator follows a structured five-phase lifecycle to transform AI coding requests into engineering outcomes. The Orchestrator itself does not perform specialist work (like coding or testing) but instead acts as a router, planner, and synthesizer, delegating tasks to specialized agents.

    The Five Phases:

    1. Init & Clarify (Phase 0): Classifies the request, validates the plan_id, normalizes intent (e.g., execute, debug, research), and assigns complexity (TRIVIAL to HIGH).
    2. Route (Phase 1): Determines the path based on state. For example, research goes to gem-researcher, while new_task or extend goes to the Planning phase.
    3. Planning (Phase 2): Generates or reuses a plan. Complexity dictates depth: TRIVIAL/LOW tasks use a direct specialist path, while MEDIUM/HIGH tasks use gem-planner and persistent plan_ids.
    4. Execution (Phase 3): Executes work using an ordered 'wave' system. Tasks are collected, scheduled (respecting concurrency limits), delegated to specialists, and gated by reviewers if necessary.
    5. Output (Phase 4): Returns a structured report containing the Plan ID, objective, progress metrics, and next steps.
  4. Understand the Knowledge Layers in Gem Team

    main

    Gem Team organizes information across six distinct layers to separate requirements, instructions, task state, and long-term learning. Understanding these layers is critical for knowing where to place documentation or where to look for context.

    LayerLocationPurpose
    PRDdocs/PRD.yamlRequirements, decisions, goals, metrics, risks, and priorities
    AGENTS.mdAGENTS.mdStable conventions, constitutional rules, and agent instructions
    Plan artifactsdocs/plan/{plan_id}/Resumable wave plans, status, outputs, and task evidence
    MemoryMemory tool or configured backendDurable facts, decisions, gotchas, patterns, and failure modes
    Skills.apm/skills/Reusable SKILL.md procedures and domain guidance
    Derived docsdocs/knowledge/Reference notes, external docs, summaries, and research outputs

    Key Constraints:

    • Plan Isolation: Every workflow receives a unique plan_id. Persistent plan artifacts store workflow state, but they do not contain project knowledge. New plans do not automatically inherit data from previous plans.
    • Stable vs. Ephemeral: AGENTS.md and repository memory are for stable knowledge. They should not be used to store task status or temporary assumptions.
  5. Maintain agent result hygiene

    main

    When handling agent results, keep them minimal and role-specific. Results should include status, failure classification, needed evidence, and actionable downstream handoffs.

    Best Practices:

    • Avoid adding universal learn or per-criterion acceptance-results fields.
    • Storage: Store detailed logs and reports in task-scoped artifacts. Return a path or manifest to these artifacts when needed.
    • Isolation: Ephemeral workflows must not read from or write to persistent plan artifacts.
  6. Promote knowledge after successful work

    main

    When a task is successfully completed and confidence is high, Gem Team can promote task-local details into stable, reusable project knowledge:

    • Product decisions: Promoted to docs/PRD.yaml.
    • Technical conventions: Promoted to AGENTS.md.
    • Patterns and gotchas: Stored in Memory (repo, session, or global).
    • Repeatable workflows: Stored in .apm/skills/ as SKILL.md playbooks, which are compiled for each target by APM.
  7. Implement Replan Guardrails

    main

    To prevent infinite loops and ensure stability, the Orchestrator enforces guardrails on the planning process. Replans are intended to revise execution details (like waves or routing) without changing the user's immutable baseline objective.

    Key Constraints:

    • Lineage: Every replan tracks its revision and replan_count. The system defaults to a maximum of two replans.
    • Scope: The Planner can revise waves, handoffs, and validation, but it cannot change the baseline objective/criteria or decide if a budget is exhausted.
    • Escalation: Empty or repetitive replans will trigger an escalation rather than continuing to loop.
    • Invalidation: Any change to waves, handoffs, or criteria automatically invalidates affected results and stale snapshots.
    • Revision Types:
      • needs_revision: Revises a plan or context.
      • needs_retry: Retries execution within its allowed cap.
    • Planner Usage: Planner revision is limited via the planner_revision_used flag.
  8. Manage Plan Identity and State Isolation

    main

    Gem Team uses explicit plan_ids to manage state and ensure isolation between tasks. A new task must never inherit the workflow state of a previous plan.

    State Mapping:

    • new_task: Triggers the generation of a new plan_id.
    • continue_plan or extend: Requires an exact, explicit plan_id. The system will never infer an ID; if it is missing or invalid, the process will block and request it.
    • Complexity Note: TRIVIAL and LOW complexity tasks use the plan_id for correlation only and do not read plan artifacts.
  9. Manage workflow state and knowledge locations

    main

    Gem Team distinguishes between stable project rules and transient workflow states. Use the following locations based on the persistence and stability required:

    PurposeLocation
    Stable project rules and conventionsAGENTS.md
    Persistent MEDIUM/HIGH workflow statedocs/plan/{plan_id}/plan.yaml
    Ephemeral TRIVIAL/LOW workflow stateIn memory (correlated by plan_id)
  10. Understand Agent and Skill sources

    main

    Gem Team defines its capabilities through specific file patterns:

    • Agent definitions: Located in .apm/agents/*.agent.md.
    • Packaged skills: Located in .apm/skills/*/SKILL.md.

    When adding or modifying a skill, ensure the name property is aligned with its directory name and that the description is specific enough for task matching. You must rebuild or repack the package before validating any generated tool targets.

  11. How the Gem Team workflow works

    main

    Gem Team operates as a multi-stage pipeline rather than a single request-response loop. The workflow follows these stages:

    1. Understand & Plan: Clarifies intent and selects the appropriate approach.
    2. Execute & Verify: Builds using TDD, verifies every task, and reviews risky boundaries.
    3. Learn & Improve: Saves patterns, skills, and decisions for future use.
    4. Done: Provides a status report and reusable knowledge.

    The system is powered by Agent definitions and packaged skills. The Orchestrator is the central component that routes work, manages context scoping, and enforces verification gates.

    Your Request
        ↓
    Understand & Plan     ← Clarify intent, pick the right approach
        ↓
    Execute & Verify      ← Build with TDD, verify every task, review risky boundaries
        ↓
    Learn & Improve       ← Save patterns, skills, decisions for next time
        ↓
    Done                  ← Status report + reusable knowledge
  12. Manage resumable tasks with plan IDs and plan.yaml

    main

    Every MEDIUM or HIGH task is designed to be resumable. The system generates a persistent plan ID and a plan.yaml file for every task. This allows work to be paused, resumed, or extended without losing context.

    Key behaviors for resumable tasks:

    • Exact plan IDs: Continuation requires the exact ID; the system does not use fuzzy matching.
    • Ordered waves: Tasks progress in waves where each wave must complete before the next begins. Evidence is carried forward through scoped handoffs.
    • Parallel execution: Independent tasks run in parallel within waves, but overlapping ownership is serialized to prevent conflicts.
    • Bounded replans: Replans revise execution details but do not change the user's goal. A maximum of two replans is allowed to prevent infinite loops.
    • Relational invariant fallbacks: If an agent output violates a conditional requirement, the Orchestrator attempts to infer intent and fill the gap rather than rejecting the work.