{"id":915,"date":"2026-05-16T14:45:19","date_gmt":"2026-05-16T06:45:19","guid":{"rendered":"https:\/\/connectword.dpdns.org\/?p=915"},"modified":"2026-05-16T14:45:19","modified_gmt":"2026-05-16T06:45:19","slug":"how-to-build-repository-level-code-intelligence-with-repowise-using-graph-analysis-dead-code-detection-decisions-and-ai-context","status":"publish","type":"post","link":"https:\/\/connectword.dpdns.org\/?p=915","title":{"rendered":"How to Build Repository-Level Code Intelligence with Repowise Using Graph Analysis, Dead-Code Detection, Decisions, and AI Context"},"content":{"rendered":"<p>In this tutorial, we explore how to use<a href=\"https:\/\/github.com\/repowise-dev\/repowise\"> <strong>Repowise<\/strong><\/a> to build repository-level intelligence for the itsdangerous Python project in a practical and reproducible way. We start with an already cloned repository, configure Repowise using the available LLM credentials, and initialize its indexing pipeline. We then inspect the generated .repowise artifacts, analyze the repository graph with PageRank and community detection, check Git intelligence, run dead-code detection, capture architectural decisions, generate a CLAUDE.md file, and interact with Repowise\u2019s MCP-style tools through the CLI. Finally, we visualize the most important nodes in the repository graph to better understand the structure, influence, dependencies, and maintenance priorities of different files or modules.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\" no-line-numbers\"><code class=\" no-wrap language-php\">import os, sys, json, subprocess, textwrap, shutil, re\nfrom pathlib import Path\nTARGET = Path(\"\/content\/itsdangerous\")\nassert TARGET.exists(), \"Run \u00a71\u2013\u00a72 first to clone the target repo.\"\nos.chdir(TARGET)\ndef sh(cmd, check=False, cwd=None, timeout=None, env=None):\n   print(f\"n$ {cmd}\")\n   proc = subprocess.run(\n       cmd, shell=True,\n       env={**os.environ, **(env or {})},\n       cwd=cwd, text=True, timeout=timeout,\n       stdout=subprocess.PIPE, stderr=subprocess.STDOUT,\n   )\n   if proc.stdout:\n       print(proc.stdout.rstrip())\n   print(f\"  \u21b3 exit {proc.returncode}\")\n   if check and proc.returncode != 0:\n       raise RuntimeError(f\"command failed (exit {proc.returncode}): {cmd}\")\n   return proc\ndef banner(t):\n   print(f\"n{'\u2550'*(len(t)+4)}n  {t}n{'\u2550'*(len(t)+4)}\")<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We begin by importing the required libraries, setting the target repository path, and moving into the itsdangerous project directory. We define a reusable sh() helper function to run shell commands, capture their output, and display exit codes clearly. We also create a banner() function so each tutorial section prints with a readable heading.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\" no-line-numbers\"><code class=\" no-wrap language-php\">banner(\"\u00a75  Building intelligence layers (fixed)\")\nsh(\"repowise --version\")\nsh(\"repowise init --help\")\nHAS_ANTHROPIC = bool(os.environ.get(\"ANTHROPIC_API_KEY\"))\nHAS_OPENAI    = bool(os.environ.get(\"OPENAI_API_KEY\"))\nHAS_LLM       = HAS_ANTHROPIC or HAS_OPENAI\nif HAS_ANTHROPIC:\n   provider, model = \"anthropic\", \"claude-sonnet-4-5\"\nelif HAS_OPENAI:\n   provider, model = \"openai\", \"gpt-4o-mini\"\nelse:\n   provider, model = \"mock\", \"mock\"\n(TARGET \/ \".repowise\").mkdir(exist_ok=True)\n(TARGET \/ \".repowise\" \/ \"config.yaml\").write_text(textwrap.dedent(f\"\"\"\n   provider: {provider}\n   model: {model}\n   embedding_model: voyage-3\n   reasoning: auto\n   git:\n     co_change_commit_limit: 200\n     blame_enabled: true\n   dead_code:\n     enabled: true\n     safe_to_delete_threshold: 0.7\n   maintenance:\n     cascade_budget: 10\n\"\"\").lstrip())\nprint(f\"Provider chosen: {provider}  |  LLM available: {HAS_LLM}\")\ninit_cmd = \"repowise init . --index-only\" if not HAS_LLM else \"repowise init .\"\nres = sh(init_cmd, timeout=20*60)\nif res.returncode != 0:\n   print(\"n<img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/17.0.2\/72x72\/274c.png\" alt=\"\u274c\" class=\"wp-smiley\" \/>  init still failed. Things to try:\")\n   print(\"   \u2022 pip install -U repowise   (older versions lacked --index-only)\")\n   print(\"   \u2022 set an ANTHROPIC_API_KEY  and re-run without --index-only\")\n   print(\"   \u2022 copy the FIRST error line above \u2014 it tells the real story\")\n   raise SystemExit(1)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We start the Repowise initialization stage by checking the installed version and viewing the supported init options. We determine whether an Anthropic or OpenAI API key is available, then automatically select the correct provider and model configuration. We write the .repowise\/config.yaml file and run Repowise initialization, using index-only mode when no LLM key is available.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\" no-line-numbers\"><code class=\" no-wrap language-php\">banner(\"\u00a76  .repowise\/ artifact tree\")\nfor p in sorted((TARGET \/ \".repowise\").rglob(\"*\")):\n   if p.is_file():\n       print(f\"  {str(p.relative_to(TARGET)):60s}  {p.stat().st_size:&gt;9,d} B\")\nbanner(\"\u00a77  Graph Intelligence\")\nimport networkx as nx\nG = None\nfor gp in (TARGET \/ \".repowise\").rglob(\"*\"):\n   if gp.is_file() and gp.suffix in {\".json\", \".gml\", \".graphml\"} and \"graph\" in gp.name.lower():\n       try:\n           if gp.suffix == \".json\":\n               data = json.loads(gp.read_text())\n               if isinstance(data, dict) and \"nodes\" in data:\n                   G = nx.node_link_graph(data)\n           elif gp.suffix == \".gml\":\n               G = nx.read_gml(gp)\n           elif gp.suffix == \".graphml\":\n               G = nx.read_graphml(gp)\n           if G is not None:\n               print(f\"Loaded {gp.name}: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges\")\n               break\n       except Exception as e:\n           print(f\"  ({gp.name}: {e})\")\npr = {}\nif G is not None:\n   pr = nx.pagerank(G)\n   print(\"nTop 10 nodes by PageRank:\")\n   for n, s in sorted(pr.items(), key=lambda x: -x[1])[:10]:\n       print(f\"  {s:.4f}  {n}\")\n   try:\n       from networkx.algorithms.community import greedy_modularity_communities\n       comms = list(greedy_modularity_communities(G.to_undirected()))\n       print(f\"n{len(comms)} communities detected; sizes:\",\n             [len(c) for c in comms[:8]])\n   except Exception as e:\n       print(f\"  communities skipped: {e}\")\nelse:\n   print(\"(no graph artifact found \u2014 your version may name it differently;\"\n         \" run  `ls -R .repowise\/`  to inspect.)\")<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We inspect the generated .repowise artifact tree to understand what files Repowise creates after indexing the repository. We then search for graph artifacts, load the repository graph using NetworkX, and print the number of nodes and edges. We calculate PageRank scores, display the most important nodes, and detect communities to understand how the codebase is structurally grouped.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\" no-line-numbers\"><code class=\" no-wrap language-php\">banner(\"\u00a78  Git Intelligence\")\nsh(\"repowise status\")\nbanner(\"\u00a79  Doc Intelligence\")\nif HAS_LLM:\n   sh('repowise search \"URL-safe token signing\"')\n   sh('repowise query \"How does Signer detect tampered payloads?\"')\nelse:\n   print(\"(skipped \u2014 no LLM key set; provider=mock can't answer real questions)\")\nbanner(\"\u00a710  Dead-code detection\")\nsh(\"repowise dead-code\")\nsh(\"repowise dead-code --safe-only\")\nbanner(\"\u00a711  Architectural decisions\")\nsrc = TARGET \/ \"src\" \/ \"itsdangerous\" \/ \"signer.py\"\nif src.exists() and \"DECISION:\" not in src.read_text():\n   src.write_text(\n       \"# DECISION: Signers are stateless by design \u2014 secrets are passed atn\"\n       \"# construction so signing can be parallelised safely.n\"\n       + src.read_text()\n   )\n   sh('git -c user.email=demo@x -c user.name=demo commit -am \"demo: inline decision\"')\nsh(\"repowise update .\")\nsh(\"repowise decision list\")\nsh(\"repowise decision health\")<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We use Repowise status to inspect Git intelligence and understand the current repository state. We then run documentation-focused search and query commands when an LLM key is available, while safely skipping them in mock mode. We also run dead-code detection, insert an inline architectural decision into signer.py, update Repowise, and check the decision list and decision health.<\/p>\n<div class=\"dm-code-snippet dark dm-normal-version default no-background-mobile\">\n<div class=\"control-language\">\n<div class=\"dm-buttons\">\n<div class=\"dm-buttons-left\">\n<div class=\"dm-button-snippet red-button\"><\/div>\n<div class=\"dm-button-snippet orange-button\"><\/div>\n<div class=\"dm-button-snippet green-button\"><\/div>\n<\/div>\n<div class=\"dm-buttons-right\"><a><span class=\"dm-copy-text\">Copy Code<\/span><span class=\"dm-copy-confirmed\">Copied<\/span><span class=\"dm-error-message\">Use a different Browser<\/span><\/a><\/div>\n<\/div>\n<pre class=\" no-line-numbers\"><code class=\" no-wrap language-php\">banner(\"\u00a712  CLAUDE.md\")\nsh(\"repowise generate-claude-md\")\nmd = TARGET \/ \"CLAUDE.md\"\nif md.exists():\n   print(md.read_text()[:4000])\nbanner(\"\u00a713  MCP tools via CLI\")\nbase = [\n   (\"get_dead_code\",            \"repowise dead-code --safe-only\"),\n   (\"search_codebase\",          'repowise search \"timestamp expiry validation\"'),\n]\nllm_only = [\n   (\"get_overview\",             'repowise query \"Architecture overview please\"'),\n   (\"get_context\",              'repowise query \"Explain signer and serializer modules\"'),\n   (\"get_risk\",                 'repowise query \"What is risky about changing signer.py?\"'),\n   (\"get_why\",                  'repowise query \"Why are signers stateless?\"'),\n   (\"get_dependency_path\",      'repowise query \"How does URLSafeSerializer reach Signer?\"'),\n   (\"get_architecture_diagram\", 'repowise query \"Produce a Mermaid diagram of the package\"'),\n]\nfor name, cmd in base + (llm_only if HAS_LLM else []):\n   print(f\"n\u2500\u2500\u2500\u2500  {name}  \u2500\u2500\u2500\u2500\")\n   sh(cmd)\nif not HAS_LLM:\n   print(\"n(7 of 9 tools above need an LLM key \u2014 set ANTHROPIC_API_KEY and re-run \u00a713.)\")\nbanner(\"\u00a714  Graph plot\")\nif G is not None:\n   import matplotlib.pyplot as plt\n   top = [n for n, _ in sorted(pr.items(), key=lambda x: -x[1])[:40]]\n   H = G.subgraph(top).copy()\n   sizes = [4000 * pr[n] \/ max(pr.values()) + 80 for n in H.nodes]\n   plt.figure(figsize=(12, 8))\n   pos = nx.spring_layout(H, seed=7, k=0.9)\n   nx.draw_networkx_edges(H, pos, alpha=0.25, arrows=False)\n   nx.draw_networkx_nodes(H, pos, node_size=sizes, node_color=\"#F59520\", alpha=0.85)\n   nx.draw_networkx_labels(H, pos,\n       labels={n: Path(n).name if isinstance(n, str) else n for n in H.nodes},\n       font_size=8)\n   plt.title(\"itsdangerous \u2014 top-40 nodes by PageRank\")\n   plt.axis(\"off\"); plt.tight_layout(); plt.show()\nprint(\"n<img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/17.0.2\/72x72\/2705.png\" alt=\"\u2705\" class=\"wp-smiley\" \/> done.\")<\/code><\/pre>\n<\/div>\n<\/div>\n<p>We generate a CLAUDE.md file to expose useful project context for AI-assisted development. We then run several Repowise MCP-style tools through CLI commands, including dead-code checks, code search, and LLM-powered architecture queries when available. Also, we visualize the top PageRank nodes in the repository graph to clearly see the most influential files and relationships.<\/p>\n<p>In conclusion, we created a practical workflow for turning a standard code repository into an intelligence-rich project workspace that supports a deeper understanding of the codebase. We used Repowise to index and inspect the codebase, uncover graph relationships, identify important files, detect potential dead code, document architectural decisions, and prepare context files for AI-assisted development. This gives us a clear view of how repository intelligence tools can improve code understanding, maintenance, refactoring, collaboration, and future onboarding, while still working in both LLM-enabled and mock-provider modes.<\/p>\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n<p>Check out\u00a0the\u00a0<strong><a href=\"https:\/\/github.com\/Marktechpost\/AI-Agents-Projects-Tutorials\/blob\/main\/AI%20Agents%20Codes\/repowise_repository_code_intelligence_tutorial_Marktechpost.ipynb\" target=\"_blank\" rel=\"noreferrer noopener\">Full Codes with Notebook here<\/a>.\u00a0<\/strong>Also,\u00a0feel free to follow us on\u00a0<strong><a href=\"https:\/\/x.com\/intent\/follow?screen_name=marktechpost\" target=\"_blank\" rel=\"noreferrer noopener\"><mark>Twitter<\/mark><\/a><\/strong>\u00a0and don\u2019t forget to join our\u00a0<strong><a href=\"https:\/\/www.reddit.com\/r\/machinelearningnews\/\" target=\"_blank\" rel=\"noreferrer noopener\">150k+ ML SubReddit<\/a><\/strong>\u00a0and Subscribe to\u00a0<strong><a href=\"https:\/\/www.aidevsignals.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">our Newsletter<\/a><\/strong>. Wait! are you on telegram?\u00a0<strong><a href=\"https:\/\/t.me\/machinelearningresearchnews\" target=\"_blank\" rel=\"noreferrer noopener\">now you can join us on telegram as well.<\/a><\/strong><\/p>\n<p>Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.?\u00a0<strong><a href=\"https:\/\/forms.gle\/MTNLpmJtsFA3VRVd9\" target=\"_blank\" rel=\"noreferrer noopener\"><mark>Connect with us<\/mark><\/a><\/strong><\/p>\n<p>The post <a href=\"https:\/\/www.marktechpost.com\/2026\/05\/15\/how-to-build-repository-level-code-intelligence-with-repowise-using-graph-analysis-dead-code-detection-decisions-and-ai-context\/\">How to Build Repository-Level Code Intelligence with Repowise Using Graph Analysis, Dead-Code Detection, Decisions, and AI Context<\/a> appeared first on <a href=\"https:\/\/www.marktechpost.com\/\">MarkTechPost<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we explore h&hellip;<\/p>\n","protected":false},"author":1,"featured_media":29,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-915","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts\/915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=915"}],"version-history":[{"count":0,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts\/915\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=\/wp\/v2\/media\/29"}],"wp:attachment":[{"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/connectword.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}