ask — Claude Code command: what it does, how to install
Answers questions about a repository using source code references, file tables, and Mermaid flowcharts.
.claude/commands/ask.mdWhat ask does
The command investigates repository files to answer technical questions strictly from code. It detects the language of your prompt and replies in that same language. Answers include a direct summary, an explanation of the flow, a table of key files, code snippets, and at least one Mermaid diagram whenever architecture or relationships are involved.
Before parsing the codebase, it resolves git remotes. It runs git remote get-url origin and inspects git rev-parse --abbrev-ref HEAD. If the origin is unclear, it stops to ask whether the project is local-only or has an upstream URL. It refuses to continue until this context is set.
This setup determines citation formatting. Remote repos get markdown links pointing directly to the branch and line number, while local folders receive (file_path:line_number). Guessing is strictly forbidden by the prompt instructions.
What it helps with
- inspect unfamiliar codebase architecture through code evidence
- locate component definitions with line-level file references
- generate Mermaid flowcharts for system relationships
- verify repository behavior without guessing or hallucinations
Example prompts for the agent
- /ask how does authentication flow work in this service?
- /ask where is the main database connection initialized?
How to install ask
Manually: put the files in place
.claude/commands/ask.mdCall it with /ask. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/ask.mdCall it with /prompts:ask. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/ask.prompt.mdManually: put the files in place
.gemini/commands/ask.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about ask
How to install ask in Claude Code?
Place the definition file at .claude/commands/ask.md in your project root. For GitHub Copilot, save it as .github/prompts/ask.prompt.md.
What does the ask command do?
It queries source files across the repository to answer questions with verified code citations, tables of key files, and Mermaid diagrams. It explicitly declines to guess when code context is missing.
How are code citations generated?
For remotes, citations link directly to GitHub via [file:line](REPO_URL/blob/BRANCH/file#Lline). For local-only repos, it uses the plain text (file_path:line_number) format.
Source text
ask.md · MIT
--- description: Ask a question about the repository using wiki context and source file references --- # Deep Wiki: Repository Q&A Answer a question about this repository grounded in actual source code. ## Source Repository Resolution (MUST DO FIRST) Before answering, resolve the source repository context: 1. **Check for git remote**: Run `git remote get-url origin` 2. **Ask the user**: _"Is this a local-only repository, or do you have a source repository URL?"_ - Remote URL → store as `REPO_URL`, use linked citations: `[file:line](REPO_URL/blob/BRANCH/file#Lline)` - Local → use `(file_path:line_number)` 3. **Determine default branch**: Run `git rev-parse --abbrev-ref HEAD` 4. **Do NOT proceed** until resolved ## Question $ARGUMENTS ## Process 1. **Detect language** of the question and respond in the **same language** 2. **Search** the codebase for files relevant to the question 3. **Read** those files to gather evidence 4. **Synthesize** an answer grounded entirely in actual code — never invent or guess ## Response Format ```markdown ## [Concise Answer Title] [1-2 paragraph direct answer] ### How It Works [Detailed explanation with inline code citations and at least 1 Mermaid diagram when the answer involves architecture, flow, or relationships] ### Key Files | File | Purpose | Source | |------|---------|--------| | `src/path/file.ts` | [Role in the system] | [linked citation] | ### Code Example <!-- Source: file_path:line_number --> [Relevant snippet from actual source, if helpful] ### Related - [Related concepts or files to explore] ``` ## Rules - ONLY use information from actual source files in this repository - NEVER invent, guess, or use external knowledge - ALWAYS cite source files inline using the resolved citation format: - **Remote**: `[src/path/file.ts:42](REPO_URL/blob/BRANCH/src/path/file.ts#L42)` - **Local**: `(src/path/file.ts:42)` - Think step by step through complex questions - If information is insufficient, say so explicitly and suggest which files to examine
© microsoft · MIT · microsoft/skills