-
Notifications
You must be signed in to change notification settings - Fork 1
Add Claude Code skill and AI Agents docs section #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,249 @@ | ||||||
| --- | ||||||
| name: physlibsearch | ||||||
| description: Semantic search over Physlib, a formal Lean 4 library of physics theorems and definitions. Use when asked to find Lean 4 declarations related to physics or mathematics, look up formal proofs, retrieve theorem signatures, or browse the Physlib module hierarchy. | ||||||
| --- | ||||||
|
|
||||||
| # PhyslibSearch API Skill | ||||||
|
|
||||||
| PhyslibSearch is a semantic search engine over **Physlib**, a Lean 4 formal library of physics and mathematics. It lets you find theorems, definitions, lemmas, and instances by describing them in natural language — no Lean syntax required. | ||||||
|
|
||||||
| **Base URL**: `https://physlibsearch.net` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## When to use this skill | ||||||
|
|
||||||
| - The user asks to find a Lean 4 theorem, definition, or proof about a physics/math concept. | ||||||
| - The user wants the formal statement (signature) of a known result (e.g. Newton's second law, Schrödinger equation). | ||||||
| - The user wants to browse what Physlib covers in a specific area. | ||||||
| - The user has a Lean 4 declaration name and wants its full record. | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Endpoints | ||||||
|
|
||||||
| ### 1. Search — `POST /search` | ||||||
|
|
||||||
| The main endpoint. Submit one or more natural language queries, get ranked results. | ||||||
|
|
||||||
| **Request** | ||||||
| ```json | ||||||
| { | ||||||
| "query": ["Newton's second law"], | ||||||
| "num_results": 10 | ||||||
| } | ||||||
| ``` | ||||||
| - `query`: array of strings (1–many queries); each runs independently and returns its own ranked list. | ||||||
| - `num_results`: 1–150, default 10. | ||||||
|
|
||||||
| **Response** — `list[list[QueryResult]]` (one list per query, ordered by relevance) | ||||||
| ```json | ||||||
| [[ | ||||||
| { | ||||||
| "result": { | ||||||
| "module_name": ["Physlib", "Mechanics", "Newton"], | ||||||
| "kind": "theorem", | ||||||
| "name": ["Physlib", "Mechanics", "Newton", "secondLaw"], | ||||||
| "signature": "theorem Physlib.Mechanics.Newton.secondLaw : ∀ (m F : ℝ), m > 0 → acceleration m F = F / m", | ||||||
| "type": "Prop", | ||||||
| "value": null, | ||||||
| "docstring": null, | ||||||
| "informal_name": "Newton's Second Law", | ||||||
| "informal_description": "For a body of mass $m > 0$ and applied force $F$, the acceleration satisfies $a = F/m$." | ||||||
| }, | ||||||
| "distance": 0.12 | ||||||
| } | ||||||
| ]] | ||||||
| ``` | ||||||
|
|
||||||
| **Key fields**: | ||||||
| - `distance` — cosine distance (lower = more relevant; 0 is perfect). | ||||||
| - `informal_name` / `informal_description` — human-readable explanation (LaTeX math). | ||||||
| - `signature` — the formal Lean 4 statement. | ||||||
| - `name` — fully-qualified name as a string array (use with `/fetch`). | ||||||
| - `kind` — `theorem`, `definition`, `lemma`, `instance`, `axiom`, etc. | ||||||
|
|
||||||
| **Example (curl)** | ||||||
| ```bash | ||||||
| curl -s -X POST https://physlibsearch.net/search \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{"query": ["quantum harmonic oscillator energy levels"], "num_results": 5}' | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ### 2. Query Expansion — `POST /expand` | ||||||
|
|
||||||
| Optionally call this **before** `/search` to improve results for technical or ambiguous queries. It uses HyDE (Hypothetical Document Embeddings): Gemini generates a plausible hypothetical Lean declaration, which is then used as the search vector. | ||||||
|
|
||||||
| **Request** — raw JSON string (the query itself, not an object) | ||||||
| ```json | ||||||
| "Schrödinger equation for a free particle" | ||||||
| ``` | ||||||
|
|
||||||
| **Response** — JSON string (expanded query or original on failure) | ||||||
| ```json | ||||||
| "theorem Physlib.QuantumMechanics.FreeParticle.schrodinger : ..." | ||||||
| ``` | ||||||
|
|
||||||
| **When to use**: For precise or highly technical queries (specific equation names, less common concepts). For broad natural-language queries, go straight to `/search`. | ||||||
|
|
||||||
| **Example flow** | ||||||
| ```bash | ||||||
| # Step 1: expand | ||||||
| EXPANDED=$(curl -s -X POST https://physlibsearch.net/expand \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '"Schrödinger equation for a free particle"') | ||||||
|
|
||||||
| # Step 2: search with expanded query | ||||||
| curl -s -X POST https://physlibsearch.net/search \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d "{\"query\": [$EXPANDED], \"num_results\": 5}" | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ### 3. Fetch by Name — `POST /fetch` | ||||||
|
|
||||||
| Retrieve full records for known Lean declaration names. Use this when you already have a name from a prior search or from the user. | ||||||
|
|
||||||
| **Request** | ||||||
| ```json | ||||||
| { | ||||||
| "query": [ | ||||||
| ["Physlib", "Mechanics", "Newton", "secondLaw"], | ||||||
| ["Physlib", "QuantumMechanics", "HarmonicOscillator", "energy"] | ||||||
| ] | ||||||
| } | ||||||
|
Comment on lines
+110
to
+117
|
||||||
| ``` | ||||||
| - Each entry is a `LeanName` — an array of strings forming the fully-qualified path. | ||||||
|
|
||||||
| **Response** — `list[Record | null]` (null for names not found, order preserved) | ||||||
|
|
||||||
| **Example (curl)** | ||||||
| ```bash | ||||||
| curl -s -X POST https://physlibsearch.net/fetch \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{"query": [["Physlib", "Mechanics", "Newton", "secondLaw"]]}' | ||||||
| ``` | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ### 4. List Modules — `GET /modules` | ||||||
|
|
||||||
| Returns all top-level Physlib modules with a count of searchable declarations. | ||||||
|
||||||
| Returns all top-level Physlib modules with a count of searchable declarations. | |
| Returns all indexed Physlib modules with a count of searchable declarations. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -84,6 +84,7 @@ export default function DocsPage() { | |||||
| ["overview", "Overview"], | ||||||
| ["how-it-works", "How it works"], | ||||||
| ["api", "API Reference"], | ||||||
| ["ai-agents", "AI Agents"], | ||||||
| ["self-hosting", "Self-hosting"], | ||||||
| ["open-source", "Open source"], | ||||||
| ["next-steps", "Next steps"], | ||||||
|
|
@@ -255,6 +256,50 @@ curl -s -X POST http://physlibsearch.net/search \\ | |||||
| /> | ||||||
| </Section> | ||||||
|
|
||||||
| <Section id="ai-agents" title="AI Agents"> | ||||||
| <p> | ||||||
| PhyslibSearch ships a{" "} | ||||||
| <a | ||||||
| href="https://claude.ai/code" | ||||||
| target="_blank" | ||||||
| rel="noopener noreferrer" | ||||||
| className="underline underline-offset-2 hover:text-foreground transition-colors" | ||||||
| > | ||||||
| Claude Code | ||||||
| </a>{" "} | ||||||
| skill that teaches any Claude agent how to call the API. Once installed, the agent can | ||||||
| search Physlib, fetch declarations by name, and expand queries with HyDE — without any | ||||||
|
||||||
| search Physlib, fetch declarations by name, and expand queries with HyDE — without any | |
| search PhysLib, fetch declarations by name, and expand queries with HyDE — without any |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The install command pulls SKILL.md from the separate physlibsearch-skill repo, but this PR also adds the skill file into this repo under .claude/skills/physlibsearch/SKILL.md. Having two sources of truth risks drift; consider either (a) referencing the in-repo file in the install instructions, or (b) removing the in-repo copy and treating the external repo as canonical. If you keep the curl-based install, pinning to a tag/commit (instead of main) would also make installs reproducible and reduce supply-chain risk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project consistently refers to the upstream library as “PhysLib” (e.g., README and frontend docs), but this skill’s description uses “Physlib”. Please align capitalization/branding throughout this skill to “PhysLib” for consistency.