dag-thinking
npx skills add https://github.com/bhagyas/dag-thinking-skill --skill dag-thinking
Agent 安装分布
Skill 文档
DAG Thinking (Directed Acyclic Graph)
Use a directed acyclic graph (DAG) as the core representation for any problem that involves dependencies. Reference: https://grokipedia.com/page/Directed_acyclic_graph
0) Decide if DAG framing fits
Use this when you can phrase the problem as:
- âX must happen before Yâ
- âY depends on Xâ
- âIf X changes, downstream things affected are â¦â
If there are feedback loops that matter, you may have cycles; handle them explicitly (see Cycle handling).
1) Build the graph
1A) Define nodes
Pick a consistent unit:
- tasks, steps, tickets, files, components, decisions, assumptions, people, etc.
1B) Define edges
Use one direction consistently:
- X â Y means âX is a prerequisite of Yâ (Y depends on X)
1C) Capture metadata
For each node, store:
- owner, status, estimate/cost, risk, notes
2) Validate the DAG
2A) Detect cycles (must do)
If cycles exist, you donât have a DAG yet.
Cycle handling (pick one):
- Break the cycle by clarifying dependency direction (often one edge is ânice-to-haveâ, not required)
- Collapse a strongly-connected set into a single âsuper-nodeâ (treat as one unit)
- Time-slice: convert feedback into iterative stages (v1 â v2)
3) Compute order (topological sorting)
Produce a valid execution order:
- pick any node with no remaining prerequisites (in-degree 0)
- execute/remove it
- repeat
If multiple nodes are available, choose by:
- shortest-first (unblock quickly)
- highest impact
- critical path urgency (see below)
4) Reduce graph complexity (optional but powerful)
4A) Transitive reduction mindset
If AâB and BâC exist, then AâC is often redundant. Prefer the minimal edge set that preserves reachability.
Practical heuristic:
- keep the edge only if removing it would change whatâs reachable
4B) Cluster by layers
Group nodes by âdistance from sourcesâ to create phases:
- Phase 0: sources
- Phase 1: depends only on Phase 0
- â¦
5) Find the critical path (for planning)
If nodes have durations/estimates:
- compute the longest path from sources to sinks
- that path dictates the minimum completion time
Output:
- critical path nodes
- slack nodes (can be delayed without affecting finish)
6) Answer typical questions with DAG outputs
- What do we do next? â topological frontier (available nodes)
- What blocks this task? â ancestors of node
- What breaks if we change X? â descendants of node
- How do we simplify? â transitive reduction / merge nodes
- Where are we stuck? â cycle detection, no available nodes
7) Output format (default)
When you apply this skill, produce:
- Nodes (with 1-line descriptions)
- Edges (X â Y)
- Cycle check result
- Proposed order (phases or linear list)
- (Optional) Critical path + slack
- Next actions
Quick prompts to ask the user (only if needed)
- âWhat counts as âdoneâ for each node?â
- âIs X truly required for Y, or just preferred?â
- âDo any dependencies create a loop?â
- âDo you care about fastest completion, lowest risk, or minimal context switching?â