Counterfactual Analysis logo

Counterfactual Analysis

Community
MattArtzAnthro
counterfactual-analysis

Test a hypothetical edit against the loaded Gephi graph without changing the real workspace. Use for what-if questions such as removing hubs, adding ties, deleting ties, or comparing structural resilience.

Overview

PublisherMattArtzAnthro
Repositorygephi-ai
Skill namecounterfactual-analysis
Stars
26
Forks
6
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by MattArtzAnthro on GitHub. Read the source before you install it.

Installation

Install the Counterfactual Analysis AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/MattArtzAnthro/gephi-ai/tree/main/plugins/gephi-network-analysis/skills/counterfactual-analysis
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MattArtzAnthro/gephi-ai.git /tmp/gephi-ai
mkdir -p .claude/skills
cp -r /tmp/gephi-ai/plugins/gephi-network-analysis/skills/counterfactual-analysis .claude/skills/counterfactual-analysis
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Counterfactual Analysis in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Counterfactual Analysis on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Counterfactual Analysis is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Counterfactual test

Answer the user's what-if question by running it as a real measurement against the graph currently loaded in Gephi, using gephi_whatif. It duplicates the current workspace, applies the edit to the copy, compares the structural profile before and after, then deletes the copy. The real graph is never touched, so this is safe to run repeatedly.

Follow the gephi skill's rules throughout; this workflow repeats only the ones it is most likely to break. Read ../gephi/references/claim-verification.md for removal tests and their comparison node.

Rules this workflow must keep

  • Asking. When a step says to ask, ask once. If the person cannot answer, is away, or asked for a finished product, use the default named in that step and remove or overwrite nothing. At the end, give one short line for each choice that changed the result, under "Choices I made"; leave the section out when every step used its obvious default. If there is no input to work on, stop and say what is needed.
  • Session start. Start with gephi_health_check. Then check which workspace is open (gephi_list_workspaces) and whether a filter is active (filter_active in replies): a filter from an earlier conversation stays on, and exports and checks then see only what it shows.
  • Ranking. To rank nodes on a metric, call gephi_query_nodes with sort_by set to the metric, columns set to the few columns you need, and limit about 10: nodes are ordered before paging, so the first page is the top of the whole graph. Without columns, every attribute of every node comes back and a long listing can overflow.

Steps

  1. Session start: gephi_health_check. If it fails, tell the user to start Gephi and stop. Call gephi_list_workspaces; if filter_active is true, say the test runs on the visible nodes only.

  2. Get the question. If the request does not specify an edit, ask what edit they want to test (one sentence is enough: "what if we removed the top hub?", "what if these two accounts stopped talking?"). Default: remove the single highest-degree node.

  3. Resolve the edit. Turn the plain-language question into gephi_whatif's edit list ({"op": "remove_node", "id": ...}, remove_nodes, add_edge, remove_edge). If the person names nodes by label rather than id ("the top hub", "Alice"), resolve the id first: gephi_query_nodes with column and value or contains for a name, or with the ranking rule for "top hub" (gephi_compute_degree first if the degree column is missing). If the name matches more than one node, ask which one. Default: the match with the highest degree, named in the report.

  4. Run gephi_whatif with the resolved edits. Only pass include_slow: true (which also compares average path length and diameter) if the graph is roughly under 3,000 nodes, the same cost gate as gephi_profile_graph.

  5. Report the difference, not a verdict. gephi_whatif returns measurements, and the framing matters:

    • Lead with the numbers that changed and by how much (components, giant-component share, density, modularity, isolates, path length if computed).
    • This is a hypothesis test, not a conclusion. Say what the change does and does not support, and note the caution that applies to any single sample: a counterfactual on a small or skewed graph, or a single removed node standing in for a whole category, can mislead.
    • Offer a rival reading where one exists (for example, "components jumped because this specific hub is also a cut vertex, not because hubs in general hold the network together. Should I test a second one to check?").
    • Add "Choices I made" only for choices that changed the result.
  6. Remind them nothing changed. The scratch copy is already deleted and they are back on their real graph. If they want to make the edit for real, point them at the direct tool (gephi_remove_node, gephi_add_edge, and so on), which gephi_snapshot and gephi_undo protect.

Frequently asked questions

What does the Counterfactual Analysis AI skill do?

Test a hypothetical edit against the loaded Gephi graph without changing the real workspace. Use for what-if questions such as removing hubs, adding ties, deleting ties, or comparing structural resilience.

Why use Counterfactual Analysis on TypingMind?

Because you install it once and use it with any model. Counterfactual Analysis is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Counterfactual Analysis in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/MattArtzAnthro/gephi-ai/tree/main/plugins/gephi-network-analysis/skills/counterfactual-analysis. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Counterfactual Analysis?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Counterfactual Analysis?

As many as you like. As long as a model supports skills, you can use Counterfactual Analysis with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Counterfactual Analysis AI skill free?

Yes. It is published on GitHub by MattArtzAnthro under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇