Extend dev command with turbo watch mode (task #189)#200
Open
Extend dev command with turbo watch mode (task #189)#200
Conversation
…ph analysis (#195) * feat: Add turbo-graph-optimization agent skill for Turborepo task graph analysis Implements fully autonomous agent skill for analyzing and optimizing Turborepo task graphs using 'turbo query' GraphQL introspection. The skill: - Works with any Turborepo 2.9+ monorepo (repo-agnostic discovery) - Discovers build targets, task types, and dependencies dynamically at runtime - Autonomously analyzes transitive dependencies and proposes optimizations - Verifies safety via static import analysis - Flags unsafe changes (dynamic imports, runtime deps) for human review - Verifies build succeeds before presenting formatted results - Provides before/after comparison tables with task breakdown Deliverables: - .agents/skills/turbo-graph-optimization/SKILL.md: Main skill documentation - .github/skills/turbo-graph-optimization: Symlink for GitHub Copilot compatibility - .agents/skills/README.md: Updated to register the new skill - ADR-0019 update: Task Graph Optimization section with CellixJS context Closes: #187 Follows: ADR-0024 (Agent Skills Framework) References: ADR-0019, ADR-0020 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * docs: Update ADR-0019 with real CellixJS task graph baseline data Replaced arbitrary example results with actual baseline data from running turbo query on CellixJS with Turborepo 2.9.3: - @apps/api#build: 26 total tasks (24 build, 1 gen, 1 audit) - @apps/ui-community#build: 7 total tasks (5 build, 1 gen, 1 audit) - @apps/docs#build: 5 total tasks (3 build, 1 gen, 1 audit) This baseline can be updated as the skill is reused and optimizations are discovered, creating a record of task graph improvements over time. * docs: Update ADR-0019 with task graph optimization analysis results Performed full optimization scan using turbo-graph-optimization workflow on CellixJS. Results show the task graph is currently well-optimized: - Total monorepo build: 36 tasks (34 build, 1 gen, 1 audit) - Per-target analysis confirms no unnecessary transitive dependencies - All task dependencies are necessary for build outputs - No uncacheable tasks, no diamond dependencies Conclusion: Repository has clean task graph. Future optimization opportunities will emerge as new packages/task types are added. * fix: Address code review comments on turbo-graph-optimization skill - Fix typo: 'no ambiguity steps' → 'no ambiguous steps' - Tighten allowed-tools to minimal required set: - Changed from Bash(*) wildcards to explicit: turbo:query, turbo:run, find, cat, grep - Make primary build task detection configurable: - Step 1: Added strategy to detect primary build task dynamically - Step 6: Updated to use detected task instead of hardcoded 'build' - Example commands: Show multiple possible build task names - Fallback: Document limitation if task cannot be reliably determined * fix: Update ADR-0019 reference to skill using GitHub link Changed broken local reference (/.agents/skills/...) to GitHub URL since the skill file exists outside the Docusaurus docs directory. Fixes Docusaurus build error for @apps/docs. * refactor: Make turbo-graph-optimization skill completely repo-agnostic Remove all CellixJS-specific references and examples: - Removed author and repository metadata (only version retained) - Removed all references to CellixJS workspace structure and ADRs - Removed references to Azure Pipelines and CI-specific details - Removed CellixJS example section and package naming examples Replace invalid GraphQL query examples with valid, copy-pastable queries: - Added proper 'turbo query --schema' example - Provided working 'turbo query packages' examples with actual field syntax - Added example queries with valid GraphQL syntax per Turborepo schema - Clarified that agents discover available fields dynamically Add generic monorepo pattern examples: - Flat structure (packages/ui, packages/api, packages/shared) - Nested/scoped structure (packages/core/domain, packages/core/persistence) - Hybrid structure (mixed scoped and app directories) - Emphasized dynamic discovery, no hardcoded assumptions Result: Skill is now completely repo-agnostic and usable by any Turborepo 2.9+ monorepo without modification. Valid query examples are now copy-pastable. * restore: Keep skill frontmatter metadata (author, repository, version) * fix: Address final code review comments on turbo-graph-optimization skill - Fix grammar: 'with reason for deferral' → 'with a reason for deferral' - Remove ADR-0020 reference from generic output example - Add separate 'CellixJS-Specific Guidance' section at end: - References ADR-0019 and ADR-0020 in dedicated subsection - Clarifies that these are CellixJS-specific implementation details - Notes that references are not required for other Turborepo monorepos Result: Skill content remains completely repo-agnostic while CellixJS-specific context (ADR references) is clearly separated into a distinct section at the end. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Reviewer's GuideIntroduces a new autonomous Turborepo task-graph optimization agent skill (with documentation and GitHub symlink) and updates the root dev script to run Turborepo in watch mode for live rebuilds, while extending the monorepo Turborepo ADR and skills README with guidance and references for this new capability. Sequence diagram for turbo-graph-optimization skill end-to-end workflowsequenceDiagram
actor Developer
participant Agent as AgentSkill_turbo_graph_optimization
participant TurboQuery as Turbo_CLI_turbo_query
participant TurboRun as Turbo_CLI_turbo_run
participant FS as Repo_Filesystem
Developer->>Agent: Invoke turbo-graph-optimization skill
Agent->>TurboQuery: turbo query --schema
TurboQuery-->>Agent: GraphQL schema
Agent->>TurboQuery: turbo query ls (discover packages)
TurboQuery-->>Agent: Packages and metadata
Agent->>FS: Read turbo.json and package.json
FS-->>Agent: Task definitions and scripts
Agent->>TurboQuery: turbo query (capture baseline per target)
TurboQuery-->>Agent: Baseline task graphs
Agent->>FS: Static import analysis on source files
FS-->>Agent: Import usage data
Agent->>FS: Apply safe changes to turbo.json
FS-->>Agent: Updated configuration
Agent->>TurboRun: turbo run build_or_primary_task
TurboRun-->>Agent: Build result
Agent->>TurboQuery: turbo query (capture after state)
TurboQuery-->>Agent: Updated task graphs
Agent-->>Developer: Before_after comparison, flags, summary
Flow diagram for turbo-graph-optimization autonomous workflowflowchart TD
A[Start_skill_invocation] --> B[Discover_build_targets_via_turbo_query_ls]
B --> C[Load_GraphQL_schema_with_turbo_query_schema]
C --> D[Capture_baseline_task_graph_per_target]
D --> E[Analyze_transitive_dependencies_and_task_types]
E --> F[Perform_static_import_analysis_on_source]
F --> G{Candidate_optimization_safe?}
G -- Yes --> H[Apply_changes_to_turbo_json_and_related_config]
G -- No --> I[Flag_change_for_human_review_and_skip_application]
H --> J[Detect_primary_build_task]
I --> J
J --> K{Primary_build_task_detected?}
K -- Yes --> L[Run_turbo_run_primary_task_for_verification]
K -- No --> M[Skip_build_verification_document_limitation]
L --> N{Build_succeeded?}
N -- Yes --> O[Capture_after_state_via_turbo_query]
N -- No --> P[Report_build_failure_and_halt]
M --> O
O --> Q[Compute_before_after_comparison_and_deltas]
Q --> R[Output_formatted_results_and_flagged_items]
R --> S[End_skill_execution]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The updated
devscript runsturbo run --watch azurite gen:watch dev, which will keep watching all three pipelines together; consider scoping--watchonly to the tasks that actually benefit from incremental rebuilds (e.g.dev) or using filters to avoid long-running infra tasks likeazuritebeing restarted unnecessarily. - Given that
pnpm run buildstill runs before entering watch mode, you might want to split the initial full build into a separate script or make it optional for faster feedback when repeatedly startingpnpm devduring development.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The updated `dev` script runs `turbo run --watch azurite gen:watch dev`, which will keep watching all three pipelines together; consider scoping `--watch` only to the tasks that actually benefit from incremental rebuilds (e.g. `dev`) or using filters to avoid long-running infra tasks like `azurite` being restarted unnecessarily.
- Given that `pnpm run build` still runs before entering watch mode, you might want to split the initial full build into a separate script or make it optional for faster feedback when repeatedly starting `pnpm dev` during development.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace root dev script to use turbo --watch for live rebuilds while developing.
Created in worktree: ../cellixjs-issue-189.
Summary by Sourcery
Introduce an autonomous Turborepo task graph optimization agent skill and enable watch-mode development builds via Turbo in the root dev workflow.
New Features:
Enhancements:
Build:
Documentation: