Install
$ agentstack add skill-arabelatso-skills-4-se-control-flow-abstraction-generator ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Control Flow Abstraction Generator
Generate abstract Control Flow Graph representations of programs.
Overview
This skill analyzes program code and generates Control Flow Graphs (CFGs) that abstract the program's control flow structure. CFGs show how execution flows through the program via nodes (statements, conditions) and edges (control transfers), making them suitable for static analysis, formal verification, and program understanding.
How to Use
Provide:
- Program code: Function or program to analyze
- Analysis scope: Function-level or program-level
- Output format (optional): Textual, DOT, JSON, or multiple
The skill will generate:
- CFG with nodes and edges
- Node types (entry, exit, statement, condition, merge)
- Edge types (sequential, true/false branches, back edges, calls)
- Optional: DOT format for visualization, JSON for tool integration
CFG Generation Workflow
Step 1: Parse Program Structure
Identify program constructs:
- Sequential statements: Assignments, expressions, declarations
- Conditional statements: if-then-else, switch-case
- Loop statements: while, for, do-while
- Function calls: Direct calls, recursive calls
- Control transfers: break, continue, return, goto
- Exception handling: try-catch-finally
Step 2: Create CFG Nodes
Generate nodes for each construct:
Entry Node: Function/program start
- Label:
ENTRYor function name - Type:
entry - Successors: First statement
Exit Node: Function/program end
- Label:
EXITorreturn - Type:
exit - Predecessors: All return points
Statement Node: Regular statement
- Label: Statement text or line number
- Type:
statement - Represents: Assignment, call, expression
Condition Node: Branch decision
- Label: Boolean expression
- Type:
condition - Successors: True branch, false branch
Merge Node: Branch join point
- Label:
MERGEor empty - Type:
merge - Predecessors: Multiple branches
Step 3: Create CFG Edges
Connect nodes with appropriate edges:
Sequential Edge: Normal flow
- From: Statement/node
- To: Next statement/node
- Label: None or
→
True Edge: Condition true branch
- From: Condition node
- To: True branch first statement
- Label:
Tortrue
False Edge: Condition false branch
- From: Condition node
- To: False branch first statement
- Label:
Forfalse
Back Edge: Loop iteration
- From: Loop body end
- To: Loop header
- Label:
↶orback
Call Edge: Function invocation (interprocedural)
- From: Call site
- To: Called function entry
- Label:
⇒orcall
Return Edge: Function return (interprocedural)
- From: Called function exit
- To: Call site return point
- Label:
⇐orreturn
Step 4: Handle Special Constructs
Loops: Create back edges from body to header
Break: Create edge from break statement to loop exit
Continue: Create back edge from continue to loop header
Return: Create edge from return to EXIT node
Exceptions: Create exception edges from try block to catch handlers
Step 5: Generate Output
Produce CFG in requested format(s):
- Textual representation
- DOT format for Graphviz
- JSON for tool integration
Example: Simple Conditional
Code:
def max_value(x, y):
if x > y:
result = x
else:
result = y
return result
CFG (Textual):
Node 1 (ENTRY):
Label: max_value
Successors: [2]
Node 2 (x > y):
Type: condition
Predecessors: [1]
Successors: [3 (true), 4 (false)]
Node 3 (result = x):
Type: statement
Predecessors: [2]
Successors: [5]
Node 4 (result = y):
Type: statement
Predecessors: [2]
Successors: [5]
Node 5 (MERGE):
Type: merge
Predecessors: [3, 4]
Successors: [6]
Node 6 (return result):
Type: statement
Predecessors: [5]
Successors: [7]
Node 7 (EXIT):
Predecessors: [6]
CFG (Visual):
ENTRY
↓
[x > y]
↓ ↓
T↓ ↓F
↓ ↓
[result=x] [result=y]
↓ ↓
└→MERGE←┘
↓
[return result]
↓
EXIT
CFG (DOT):
digraph CFG {
node [shape=box];
n1 [label="ENTRY", shape=ellipse];
n2 [label="x > y", shape=diamond];
n3 [label="result = x"];
n4 [label="result = y"];
n5 [label="MERGE", shape=circle];
n6 [label="return result"];
n7 [label="EXIT", shape=ellipse];
n1 -> n2;
n2 -> n3 [label="T", color=green];
n2 -> n4 [label="F", color=red];
n3 -> n5;
n4 -> n5;
n5 -> n6;
n6 -> n7;
}
Example: While Loop
Code:
def sum_to_n(n):
sum = 0
i = 0
while i threshold:
result.append(item * 2)
else:
if item threshold] ↑
↓T ↓F ↑
[result.append [item ():
Type:
Predecessors: []
Successors: []
DOT Format (Graphviz)
Graph visualization format:
digraph CFG {
node [shape=box];
n1 [label="...", shape=...];
n1 -> n2 [label="...", color=...];
}
Generate PNG/SVG with: dot -Tpng cfg.dot -o cfg.png
JSON Format
Machine-readable for tool integration:
{
"nodes": [
{"id": 1, "label": "...", "type": "..."}
],
"edges": [
{"from": 1, "to": 2, "type": "..."}
]
}
Analysis Levels
Function-Level (Intraprocedural)
Scope: Single function Nodes: Statements within function Edges: Control flow within function Calls: Treated as single statement nodes
Use cases:
- Function-level analysis
- Loop detection
- Path analysis within function
Program-Level (Interprocedural)
Scope: Multiple functions Nodes: Statements across all functions Edges: Control flow + call/return edges Calls: Explicit call and return edges
Use cases:
- Whole-program analysis
- Call graph construction
- Interprocedural dataflow
CFG Properties
Dominance
Node A dominates node B if every path from ENTRY to B passes through A.
Uses: Loop header identification, optimization
Post-Dominance
Node A post-dominates node B if every path from B to EXIT passes through A.
Uses: Control dependence, merge point identification
Reachability
Node B is reachable from node A if there exists a path from A to B.
Uses: Dead code detection, path analysis
Strongly Connected Components
Maximal set of nodes where every node is reachable from every other.
Uses: Loop detection, cycle analysis
Common Patterns
Sequential Statements
Pattern: Linear flow See: [cfgpatterns.md](references/cfgpatterns.md#sequential-statements)
If-Then-Else
Pattern: Diamond shape with merge See: [cfgpatterns.md](references/cfgpatterns.md#conditional-statements)
While Loop
Pattern: Back edge from body to header See: [cfgpatterns.md](references/cfgpatterns.md#loop-statements)
Break/Continue
Pattern: Direct edges to exit/header See: [cfgpatterns.md](references/cfgpatterns.md#loop-statements)
Try-Catch
Pattern: Exception edges to handlers See: [cfgpatterns.md](references/cfgpatterns.md#exception-handling)
References
Detailed CFG construction patterns:
- [cfgpatterns.md](references/cfgpatterns.md): Comprehensive patterns for all control flow constructs with examples
Load this reference when:
- Need detailed patterns for specific constructs
- Working with complex nested structures
- Want to see all output format examples
- Need CFG property definitions
Tips
- Start with entry/exit: Always create ENTRY and EXIT nodes first
- Handle loops carefully: Identify loop headers and create back edges
- Merge branches: Create explicit merge nodes after conditionals
- Label edges clearly: Use T/F for branches, mark back edges
- Consider scope: Choose function-level or program-level based on use case
- Visualize complex CFGs: Use DOT format for large graphs
- Validate structure: Check that all nodes are reachable from ENTRY
- Document assumptions: Note how you handle language-specific constructs
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: ArabelaTso
- Source: ArabelaTso/Skills-4-SE
- License: Apache-2.0
- Homepage: https://ArabelaTso.github.io/Skills-4-SE/
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.