Asi amp-api-awareness
Extract hidden Amp API patterns from local thread data via DuckDB analysis
install
source · Clone the upstream repo
git clone https://github.com/plurigrid/asi
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/plurigrid/asi "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/amp-api-awareness" ~/.claude/skills/plurigrid-asi-amp-api-awareness-f1dae4 && rm -rf "$T"
manifest:
skills/amp-api-awareness/SKILL.mdsource content
Amp API Awareness
Discover Amp's undocumented API by mining local thread storage.
Data Sources
| Source | Path | Format |
|---|---|---|
| Threads | | JSON per thread |
| History | | JSONL sessions |
| Projects | | JSONL per project |
Quick Extraction
Count all threads
ls ~/.local/share/amp/threads/*.json | wc -l
Sample thread structure
cat ~/.local/share/amp/threads/T-*.json | head -1 | jq 'keys' # Expected: ["id", "title", "created", "updatedAt", "messages", ...]
DuckDB unified query
-- Load all threads CREATE TABLE amp_threads AS SELECT * FROM read_json('~/.local/share/amp/threads/*.json', columns={id: 'VARCHAR', title: 'VARCHAR', created: 'BIGINT', messages: 'JSON[]', creatorUserID: 'VARCHAR'}, ignore_errors=true); -- Extract message patterns SELECT id, title, len(messages) as msg_count, abs(hash(id)) % 3 - 1 as trit FROM amp_threads ORDER BY created DESC LIMIT 20;
API Discovery Patterns
1. Tool Usage Extraction
-- Find all tool invocations across threads SELECT json_extract_string(msg, '$.type') as msg_type, json_extract_string(msg, '$.name') as tool_name, count(*) as usage_count FROM amp_threads, unnest(messages) as t(msg) WHERE json_extract_string(msg, '$.type') = 'tool_use' GROUP BY 1, 2 ORDER BY usage_count DESC;
2. MCP Server Detection
-- Extract MCP patterns from content SELECT DISTINCT regexp_extract(content, 'mcp__([a-z_]+)__', 1) as mcp_server FROM ( SELECT json_extract_string(msg, '$.content') as content FROM amp_threads, unnest(messages) as t(msg) ) WHERE mcp_server IS NOT NULL;
3. Thread Schema Discovery
// TypeScript extraction from thread JSON interface AmpThread { id: string; // T-{uuid} title: string; created: number; // Unix timestamp ms updatedAt: string; // ISO8601 creatorUserID: string; messages: AmpMessage[]; } interface AmpMessage { role: 'user' | 'assistant'; content: ContentBlock[]; } type ContentBlock = | { type: 'text'; text: string } | { type: 'thinking'; thinking: string } | { type: 'tool_use'; id: string; name: string; input: unknown } | { type: 'tool_result'; tool_use_id: string; content: string };
Full Statistics (2,424 threads, 118,951 messages)
Core Tools
| Tool | Invocations | Purpose |
|---|---|---|
| 30,786 | Shell commands |
| 10,373 | File reading |
| 6,884 | File modification |
| 5,373 | File creation |
| 3,862 | Task management |
| 2,837 | Pattern search |
| 1,798 | Skill loading |
| 1,314 | Sub-agent dispatch |
| 1,121 | File patterns |
| 1,014 | Diagrams |
| 892 | Thread search |
| 834 | Thread content |
MCP Servers
| Server | Invocations | Top Function |
|---|---|---|
| 1,715 | (1,039) |
| 1,323 | (1,150) |
| 1,284 | (206), (151) |
| 405 | (241) |
| 253 | (89) |
| 135 | Binary analysis |
| 130 | ML model access |
| ~100 | AST queries |
Agent Modes
: 2,398 threads (99%)smart
: 1 threadrush
: 25 threadsnil
Known Endpoints & APIs
| Endpoint/Command | Access | Notes |
|---|---|---|
| Public URL | Thread viewer |
| Auth required | API key, account management |
tool | Agent API | Query by DSL, returns |
tool | Agent API | Extract thread content by goal |
CLI Commands
| Command | Purpose |
|---|---|
| Lists threads with ID, title, visibility, messages |
| Set: private, public, unlisted, workspace, group |
| Share with Amp support for debugging |
/ | Auth management |
| Skill management |
| MCP server configuration |
Visibility Levels
| Level | Description |
|---|---|
| Only creator can see |
| All workspace members can see |
| Specific group access |
| Anyone with link |
| Anyone with link (not indexed) |
User ID Format
From
find_thread API:
creatorUserID: "user_01JZZT0P50CFR9XKKW8SXQ7J74"
- Prefix:
user_ - Body: 26-char ULID-like identifier (TypeID format)
Workspace Member Discovery
Query workspace threads to find all
creatorUserID values:
# Via find_thread DSL (repo: filter scopes to workspace) find_thread "repo:i after:30d"
Example: Two users discovered in workspace
i:
| User ID | Threads (7d) |
|---|---|
| 6 |
| 4 |
Local Storage
| Path | Contents |
|---|---|
| API key () |
| Current |
| Thread JSON files |
| User preferences, MCP configs |
Environment Variables
| Variable | Purpose |
|---|---|
| Access token (overrides stored key) |
| Service URL (default: https://ampcode.com/) |
| Custom settings path |
GF(3) Classification
Threads are colored by hash:
abs(hash(id)) % 3 - 1 as trit -- -1 = MINUS (validation threads) -- 0 = ERGODIC (coordination) -- +1 = PLUS (generation)
Usage
# Export to DuckDB duckdb amp-threads.duckdb -c " CREATE TABLE threads AS SELECT * FROM read_json('~/.local/share/amp/threads/*.json', ignore_errors=true); " # Query patterns duckdb amp-threads.duckdb -c " SELECT title, created FROM threads ORDER BY created DESC LIMIT 10; "
Underlying LLM Cost Estimates (Jan 2026)
Amp uses multiple LLMs. Pricing per 1M tokens (input/output):
Claude 4.5 Series (Anthropic)
| Model | Input | Output | Cache Write | Cache Read | Context |
|---|---|---|---|---|---|
| Opus 4.5 | $5.00 | $25.00 | $6.25 | $0.50 | 200K |
| Sonnet 4.5 | $3.00 | $15.00 | $3.75 | $0.30 | 200K/1M |
| Haiku 4.5 | $1.00 | $5.00 | $1.25 | $0.10 | 200K |
Sonnet 4.5 >200K context: $6/$22.50 per 1M tokens
Gemini 3 Series (Google)
| Model | Input | Output | Context |
|---|---|---|---|
| Gemini 3 Pro (≤200K) | $2.00 | $12.00 | 1M |
| Gemini 3 Pro (>200K) | $4.00 | $18.00 | 1M |
| Gemini 3 Flash | $0.50 | $3.00 | 1M |
Amp Mode → Model Mapping
| Mode | Primary Model | Cost Profile |
|---|---|---|
| Claude Opus 4.5 | $5/$25 (flagship) |
| Claude Haiku 4.5 | $1/$5 (efficient) |
| Extended context | +50-100% premium |
Thread Usage Distribution (from 2,424 threads)
| Model | Occurrences | Est. % Usage |
|---|---|---|
| 2,312 | 95.4% |
| 27 | 1.1% |
| 5 | 0.2% |
| 1 | 0.04% |
Cost Optimizations Available
| Strategy | Savings | Notes |
|---|---|---|
| Prompt Caching | Up to 90% | For repeated system prompts |
| Batch API | 50% | Async processing |
| Rush Mode | ~80% | Haiku vs Opus |
| Token Optimization | Variable | Concise prompts |
Amp Pricing Pass-Through
Amp passes LLM costs directly with no markup for individuals/teams.
- Free tier: $10/day grant (all modes including Opus 4.5)
- Enterprise: +50% over individual/team rates
Example Cost Calculation
Typical thread (~50 messages, 100K tokens total):
Opus 4.5: ~$1.50/thread (50K in × $5 + 50K out × $25) Haiku 4.5: ~$0.30/thread (80% savings) Gemini 3 Pro: ~$0.70/thread (mid-tier)
Related Skills
- IES analytics layerduckdb-ies
- Team/session trackingamp-team-usage
- Cross-agent session DBunified-reafference
SDF Interleaving
This skill connects to Software Design for Flexibility (Hanson & Sussman, 2021):
Primary Chapter: 10. Adventure Game Example
Concepts: autonomous agent, game, synthesis
GF(3) Balanced Triad
amp-api-awareness (−) + SDF.Ch10 (+) + [balancer] (○) = 0
Skill Trit: -1 (MINUS - verification)
Secondary Chapters
- Ch2: Domain-Specific Languages
- Ch9: Generic Procedures
- Ch8: Degeneracy
- Ch4: Pattern Matching
- Ch5: Evaluation
- Ch6: Layering
Connection Pattern
Adventure games synthesize techniques. This skill integrates multiple patterns.