Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

fix: ask user for temp directory and improve prompt discovery

Sreeram42074bb210d5
diff --git a/understand-anything-plugin/skills/understand/SKILL.md b/understand-anything-plugin/skills/understand/SKILL.md
index 35b28d38..3954054f 100644
--- a/understand-anything-plugin/skills/understand/SKILL.md
+++ b/understand-anything-plugin/skills/understand/SKILL.md
@@ -20,18 +20,29 @@ Analyze the current codebase and produce a `knowledge-graph.json` file in `.unde
Determine whether to run a full analysis or incremental update.
-1. Set `PROJECT_ROOT` to the current working directory.
-2. Get the current git commit hash:
+1. **STOP and ask the user where temporary scripts and intermediate files should be written.** You MUST wait for the user's response before proceeding to step 2 or any other step. Do NOT read prompt templates, launch subagents, or begin any analysis until this question is answered.
+
+ Ask the user:
+ > Where should I write temporary scripts and intermediate files during analysis?
+ > 1. **Project directory** (recommended): `.understand-anything/tmp/` — stays within the project
+ > 2. **System temp**: `/tmp/` — may require permissions outside the project
+
+ After the user responds, store the chosen path as `$TMP_DIR`. Create it: `mkdir -p $TMP_DIR`.
+
+ All subagent prompts reference `$TMP_DIR` for script files and intermediate JSON. When dispatching subagents, replace any `/tmp/ua-` paths in the prompt templates with `$TMP_DIR/ua-` so scripts and results are written to the user's chosen location.
+
+2. Set `PROJECT_ROOT` to the current working directory.
+3. Get the current git commit hash:
```bash
git rev-parse HEAD
```
-3. Create the intermediate output directory:
+4. Create the intermediate output directory:
```bash
mkdir -p $PROJECT_ROOT/.understand-anything/intermediate
```
-4. Check if `$PROJECT_ROOT/.understand-anything/knowledge-graph.json` exists. If it does, read it.
-5. Check if `$PROJECT_ROOT/.understand-anything/meta.json` exists. If it does, read it to get `gitCommitHash`.
-6. **Decision logic:**
+5. Check if `$PROJECT_ROOT/.understand-anything/knowledge-graph.json` exists. If it does, read it.
+6. Check if `$PROJECT_ROOT/.understand-anything/meta.json` exists. If it does, read it to get `gitCommitHash`.
+7. **Decision logic:**
| Condition | Action |
|---|---|
@@ -46,7 +57,7 @@ Determine whether to run a full analysis or incremental update.
```
If this returns no files, report "Graph is up to date" and STOP.
-7. **Collect project context for subagent injection:**
+8. **Collect project context for subagent injection:**
- Read `README.md` (or `README.rst`, `readme.md`) from `$PROJECT_ROOT` if it exists. Store as `$README_CONTENT` (first 3000 characters).
- Read the primary package manifest (`package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `pom.xml`) if it exists. Store as `$MANIFEST_CONTENT`.
- Capture the top-level directory tree:
@@ -102,8 +113,8 @@ For each batch, dispatch a subagent using the prompt template at `./file-analyze
**Build the combined prompt template:**
1. Read the base template at `./file-analyzer-prompt.md`.
-2. **Language context injection:** For each language detected in Phase 1, check if `./languages/<language-id>.md` exists. If it does, read it and append its content after the base template under a `## Language Context` header.
-3. **Framework addendum injection:** For each framework detected in Phase 1, check if `./frameworks/<framework-id-lowercase>.md` exists. If it does, read it and append its full content after the language context. This replaces any hardcoded framework-specific conditionals.
+2. **Language context injection:** For each language detected in Phase 1 (e.g., `python`), read the file at `./languages/<language-id>.md` (e.g., `./languages/python.md`) and append its content after the base template under a `## Language Context` header. These files are in the `languages/` subdirectory next to this SKILL.md file. Use `ls ./languages/` to discover available language files if needed.
+3. **Framework addendum injection:** For each framework detected in Phase 1 (e.g., `Django`), read the file at `./frameworks/<framework-id-lowercase>.md` (e.g., `./frameworks/django.md`) and append its full content after the language context. These files are in the `frameworks/` subdirectory next to this SKILL.md file. Use `ls ./frameworks/` to discover available framework files if needed.
Then for each batch pass the combined template content as the subagent's prompt, appending the following additional context:
@@ -161,8 +172,8 @@ Merge all file-analyzer results into a single set of nodes and edges. Then perfo
**Build the combined prompt template:**
1. Read the base template at `./architecture-analyzer-prompt.md`.
-2. **Language context injection:** For each language detected in Phase 1, check if `./languages/<language-id>.md` exists. If it does, read it and append its content after the base template under a `## Language Context` header.
-3. **Framework addendum injection:** For each framework detected in Phase 1, check if `./frameworks/<framework-id-lowercase>.md` exists. If it does, read it and append its full content after the language context.
+2. **Language context injection:** For each language detected in Phase 1 (e.g., `python`), read the file at `./languages/<language-id>.md` (e.g., `./languages/python.md`) and append its content after the base template under a `## Language Context` header. These files are in the `languages/` subdirectory next to this SKILL.md file.
+3. **Framework addendum injection:** For each framework detected in Phase 1 (e.g., `Django`), read the file at `./frameworks/<framework-id-lowercase>.md` (e.g., `./frameworks/django.md`) and append its full content after the language context. These files are in the `frameworks/` subdirectory next to this SKILL.md file.
Pass the combined content as the subagent's prompt, appending the following additional context:
@@ -405,6 +416,7 @@ Pass these parameters in the dispatch prompt:
3. Clean up intermediate files:
```bash
rm -rf $PROJECT_ROOT/.understand-anything/intermediate
+ rm -rf $TMP_DIR
```
4. Report a summary to the user containing: