Get the FREE Ultimate OpenClaw Setup Guide →

search

Scanned
npx machina-cli add skill ConaryLabs/Mira/search --openclaw
Files (1)
SKILL.md
2.4 KB

Semantic Code Search

Search the codebase using Mira's semantic search to find code by meaning, not just text.

Query: $ARGUMENTS

Instructions

No arguments -- ask what to search for

If no query is provided ($ARGUMENTS is empty), ask the user what they want to find. Suggest examples:

  • "authentication middleware"
  • "error handling patterns"
  • "database connection logic"

With a query -- semantic search

If a query is provided:

  1. Use the mcp__mira__code tool:
    code(action="search", query="<the query>", limit=10)
    
  2. Present results clearly with:
    • File path and line numbers -- linked for navigation
    • Relevance score -- how closely the code matches the intent
    • Code snippet -- a short preview of the matching code
  3. Group related results if they come from the same module
  4. Omit results with very low relevance scores

When results are empty or low-relevance

If semantic search returns no results or only poor matches:

  1. Suggest refining the query with more specific terms
  2. Try a keyword fallback using Grep for literal string matching
  3. Note that semantic search works best with descriptive intent ("how sessions are created") rather than exact identifiers ("session_start")

Example Output

Found 3 results for "session cleanup":

1. src/session/manager.rs:142-158 (score: 0.84)
   fn cleanup_expired_sessions() -- removes sessions older than TTL

2. src/hooks/stop.rs:45-62 (score: 0.71)
   fn on_stop() -- snapshots and archives the current session

3. src/background/tasks.rs:88-95 (score: 0.65)
   fn schedule_cleanup() -- periodic session maintenance task

Follow-Up Hints

After showing results, suggest next steps:

  • Read a result file for full context
  • code(action="callers", function_name="...") -- trace what calls a found function
  • code(action="symbols", file_path="...") -- explore the structure of a result file
  • Refine the query if results do not match the intent

Example Usage

/mira:search authentication middleware
/mira:search error handling patterns
/mira:search database connection pooling
/mira:search how are embeddings generated

Source

git clone https://github.com/ConaryLabs/Mira/blob/main/plugin/skills/search/SKILL.mdView on GitHub

Overview

Semantic Code Search lets you find code by concept or intent rather than exact text. It uses Mira's semantic search to match ideas like authentication, error handling, or database logic across the codebase. If no query is given, it prompts you to specify what to search for.

How This Skill Works

With a query, Mira runs a semantic search via the code action search tool with limit=10. Results are shown with file path and line numbers, a relevance score, and a code snippet, and related hits can be grouped by module; low relevance hits are omitted.

When to Use It

  • When you want to find code that implements a concept such as authentication middleware or error handling patterns
  • When you need to locate where a feature is implemented or how a function works within the codebase
  • When searching by meaning to compare different approaches to the same problem across modules
  • When you want to understand how a feature is constructed by exploring related modules and functions
  • When results are empty or have low relevance and you need to refine the query or fallback to a keyword search

Quick Start

  1. Step 1: Run a query with the search command, for example /mira:search authentication middleware, or omit the query to be prompted
  2. Step 2: Mira uses semantic search with code action search and returns up to 10 results showing file paths, line ranges, scores, and code snippets
  3. Step 3: Review results, group by module if needed, and use follow up hints like code(action=callers) or code(action=symbols) to explore further

Best Practices

  • Use descriptive intents rather than single identifiers (example concept like authentication or session management)
  • Start with high level concepts and then narrow with more specific terms
  • Limit results to a manageable set (for example 10) and group by module when possible
  • Review relevance scores first to filter out weak matches
  • If results are poor, refine the query or try a keyword grep fallback

Example Use Cases

  • Found 3 results for authentication middleware: src/server/auth/middleware.rs 12-28 (score: 0.88); fn authenticate_user; src/api/auth.rs 45-60 (score: 0.74); fn login; src/hooks/auth.rs 10-22 (score: 0.66); fn require_auth
  • Found 2 results for error handling patterns: src/errors/patterns.rs 101-118 (score: 0.81); fn map_error; src/utils/error.rs 20-35 (score: 0.72); fn format_error
  • Found 2 results for database connection logic: src/db/connection.rs 40-58 (score: 0.84); fn connect; src/db/pool.rs 12-28 (score: 0.69); fn create_pool
  • Found 1 result for how embeddings are generated: src/embeddings/generator.rs 5-28 (score: 0.65); fn generate_embeddings
  • Found 3 results for how sessions are created: src/sessions/manager.rs 22-38 (score: 0.79); fn create_session; src/sessions/guards.rs 15-28 (score: 0.66); fn start_session; src/logging/session.rs 30-40 (score: 0.61); fn log_session_start

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers