mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
Revert "feat: add orchestration workflows and harness skills"
This reverts commit cb43402d7d.
This commit is contained in:
@@ -1,333 +0,0 @@
|
||||
---
|
||||
name: claude-api
|
||||
description: Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Claude API
|
||||
|
||||
Build applications with the Anthropic Claude API and SDKs.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- Building applications that call the Claude API
|
||||
- Code imports `anthropic` (Python) or `@anthropic-ai/sdk` (TypeScript)
|
||||
- User asks about Claude API patterns, tool use, streaming, or vision
|
||||
- Implementing agent workflows with Claude Agent SDK
|
||||
- Optimizing API costs, token usage, or latency
|
||||
|
||||
## Model Selection
|
||||
|
||||
| Model | ID | Best For |
|
||||
|-------|-----|----------|
|
||||
| Opus 4.6 | `claude-opus-4-6` | Complex reasoning, architecture, research |
|
||||
| Sonnet 4.6 | `claude-sonnet-4-6` | Balanced coding, most development tasks |
|
||||
| Haiku 4.5 | `claude-haiku-4-5-20251001` | Fast responses, high-volume, cost-sensitive |
|
||||
|
||||
Default to Sonnet 4.6 unless the task requires deep reasoning (Opus) or speed/cost optimization (Haiku).
|
||||
|
||||
## Python SDK
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
pip install anthropic
|
||||
```
|
||||
|
||||
### Basic Message
|
||||
|
||||
```python
|
||||
import anthropic
|
||||
|
||||
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from env
|
||||
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=1024,
|
||||
messages=[
|
||||
{"role": "user", "content": "Explain async/await in Python"}
|
||||
]
|
||||
)
|
||||
print(message.content[0].text)
|
||||
```
|
||||
|
||||
### Streaming
|
||||
|
||||
```python
|
||||
with client.messages.stream(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=1024,
|
||||
messages=[{"role": "user", "content": "Write a haiku about coding"}]
|
||||
) as stream:
|
||||
for text in stream.text_stream:
|
||||
print(text, end="", flush=True)
|
||||
```
|
||||
|
||||
### System Prompt
|
||||
|
||||
```python
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=1024,
|
||||
system="You are a senior Python developer. Be concise.",
|
||||
messages=[{"role": "user", "content": "Review this function"}]
|
||||
)
|
||||
```
|
||||
|
||||
## TypeScript SDK
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
npm install @anthropic-ai/sdk
|
||||
```
|
||||
|
||||
### Basic Message
|
||||
|
||||
```typescript
|
||||
import Anthropic from "@anthropic-ai/sdk";
|
||||
|
||||
const client = new Anthropic(); // reads ANTHROPIC_API_KEY from env
|
||||
|
||||
const message = await client.messages.create({
|
||||
model: "claude-sonnet-4-6",
|
||||
max_tokens: 1024,
|
||||
messages: [
|
||||
{ role: "user", content: "Explain async/await in TypeScript" }
|
||||
],
|
||||
});
|
||||
console.log(message.content[0].text);
|
||||
```
|
||||
|
||||
### Streaming
|
||||
|
||||
```typescript
|
||||
const stream = client.messages.stream({
|
||||
model: "claude-sonnet-4-6",
|
||||
max_tokens: 1024,
|
||||
messages: [{ role: "user", content: "Write a haiku" }],
|
||||
});
|
||||
|
||||
for await (const event of stream) {
|
||||
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
|
||||
process.stdout.write(event.delta.text);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Tool Use
|
||||
|
||||
Define tools and let Claude call them:
|
||||
|
||||
```python
|
||||
tools = [
|
||||
{
|
||||
"name": "get_weather",
|
||||
"description": "Get current weather for a location",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {"type": "string", "description": "City name"},
|
||||
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
|
||||
},
|
||||
"required": ["location"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=1024,
|
||||
tools=tools,
|
||||
messages=[{"role": "user", "content": "What's the weather in SF?"}]
|
||||
)
|
||||
|
||||
# Handle tool use response
|
||||
for block in message.content:
|
||||
if block.type == "tool_use":
|
||||
# Execute the tool with block.input
|
||||
result = get_weather(**block.input)
|
||||
# Send result back
|
||||
follow_up = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=1024,
|
||||
tools=tools,
|
||||
messages=[
|
||||
{"role": "user", "content": "What's the weather in SF?"},
|
||||
{"role": "assistant", "content": message.content},
|
||||
{"role": "user", "content": [
|
||||
{"type": "tool_result", "tool_use_id": block.id, "content": str(result)}
|
||||
]}
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Vision
|
||||
|
||||
Send images for analysis:
|
||||
|
||||
```python
|
||||
import base64
|
||||
|
||||
with open("diagram.png", "rb") as f:
|
||||
image_data = base64.standard_b64encode(f.read()).decode("utf-8")
|
||||
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=1024,
|
||||
messages=[{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": image_data}},
|
||||
{"type": "text", "text": "Describe this diagram"}
|
||||
]
|
||||
}]
|
||||
)
|
||||
```
|
||||
|
||||
## Extended Thinking
|
||||
|
||||
For complex reasoning tasks:
|
||||
|
||||
```python
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=16000,
|
||||
thinking={
|
||||
"type": "enabled",
|
||||
"budget_tokens": 10000
|
||||
},
|
||||
messages=[{"role": "user", "content": "Solve this math problem step by step..."}]
|
||||
)
|
||||
|
||||
for block in message.content:
|
||||
if block.type == "thinking":
|
||||
print(f"Thinking: {block.thinking}")
|
||||
elif block.type == "text":
|
||||
print(f"Answer: {block.text}")
|
||||
```
|
||||
|
||||
## Prompt Caching
|
||||
|
||||
Cache large system prompts or context to reduce costs:
|
||||
|
||||
```python
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=1024,
|
||||
system=[
|
||||
{"type": "text", "text": large_system_prompt, "cache_control": {"type": "ephemeral"}}
|
||||
],
|
||||
messages=[{"role": "user", "content": "Question about the cached context"}]
|
||||
)
|
||||
# Check cache usage
|
||||
print(f"Cache read: {message.usage.cache_read_input_tokens}")
|
||||
print(f"Cache creation: {message.usage.cache_creation_input_tokens}")
|
||||
```
|
||||
|
||||
## Batches API
|
||||
|
||||
Process large volumes asynchronously at 50% cost reduction:
|
||||
|
||||
```python
|
||||
batch = client.messages.batches.create(
|
||||
requests=[
|
||||
{
|
||||
"custom_id": f"request-{i}",
|
||||
"params": {
|
||||
"model": "claude-sonnet-4-6",
|
||||
"max_tokens": 1024,
|
||||
"messages": [{"role": "user", "content": prompt}]
|
||||
}
|
||||
}
|
||||
for i, prompt in enumerate(prompts)
|
||||
]
|
||||
)
|
||||
|
||||
# Poll for completion
|
||||
while True:
|
||||
status = client.messages.batches.retrieve(batch.id)
|
||||
if status.processing_status == "ended":
|
||||
break
|
||||
time.sleep(30)
|
||||
|
||||
# Get results
|
||||
for result in client.messages.batches.results(batch.id):
|
||||
print(result.result.message.content[0].text)
|
||||
```
|
||||
|
||||
## Claude Agent SDK
|
||||
|
||||
Build multi-step agents:
|
||||
|
||||
```python
|
||||
# Note: Agent SDK API surface may change — check official docs
|
||||
import anthropic
|
||||
|
||||
# Define tools as functions
|
||||
tools = [{
|
||||
"name": "search_codebase",
|
||||
"description": "Search the codebase for relevant code",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {"query": {"type": "string"}},
|
||||
"required": ["query"]
|
||||
}
|
||||
}]
|
||||
|
||||
# Run an agentic loop with tool use
|
||||
client = anthropic.Anthropic()
|
||||
messages = [{"role": "user", "content": "Review the auth module for security issues"}]
|
||||
|
||||
while True:
|
||||
response = client.messages.create(
|
||||
model="claude-sonnet-4-6",
|
||||
max_tokens=4096,
|
||||
tools=tools,
|
||||
messages=messages,
|
||||
)
|
||||
if response.stop_reason == "end_turn":
|
||||
break
|
||||
# Handle tool calls and continue the loop
|
||||
messages.append({"role": "assistant", "content": response.content})
|
||||
# ... execute tools and append tool_result messages
|
||||
```
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
| Strategy | Savings | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| Prompt caching | Up to 90% on cached tokens | Repeated system prompts or context |
|
||||
| Batches API | 50% | Non-time-sensitive bulk processing |
|
||||
| Haiku instead of Sonnet | ~75% | Simple tasks, classification, extraction |
|
||||
| Shorter max_tokens | Variable | When you know output will be short |
|
||||
| Streaming | None (same cost) | Better UX, same price |
|
||||
|
||||
## Error Handling
|
||||
|
||||
```python
|
||||
from anthropic import APIError, RateLimitError, APIConnectionError
|
||||
|
||||
try:
|
||||
message = client.messages.create(...)
|
||||
except RateLimitError:
|
||||
# Back off and retry
|
||||
time.sleep(60)
|
||||
except APIConnectionError:
|
||||
# Network issue, retry with backoff
|
||||
pass
|
||||
except APIError as e:
|
||||
print(f"API error {e.status_code}: {e.message}")
|
||||
```
|
||||
|
||||
## Environment Setup
|
||||
|
||||
```bash
|
||||
# Required
|
||||
export ANTHROPIC_API_KEY="your-api-key-here"
|
||||
|
||||
# Optional: set default model
|
||||
export ANTHROPIC_MODEL="claude-sonnet-4-6"
|
||||
```
|
||||
|
||||
Never hardcode API keys. Always use environment variables.
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "Claude API"
|
||||
short_description: "Anthropic Claude API patterns and SDKs"
|
||||
brand_color: "#D97706"
|
||||
default_prompt: "Build applications with the Claude API using Messages, tool use, streaming, and Agent SDK"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -1,187 +0,0 @@
|
||||
---
|
||||
name: crosspost
|
||||
description: Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Crosspost
|
||||
|
||||
Distribute content across multiple social platforms with platform-native adaptation.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to post content to multiple platforms
|
||||
- Publishing announcements, launches, or updates across social media
|
||||
- Repurposing a post from one platform to others
|
||||
- User says "crosspost", "post everywhere", "share on all platforms", or "distribute this"
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Never post identical content cross-platform.** Each platform gets a native adaptation.
|
||||
2. **Primary platform first.** Post to the main platform, then adapt for others.
|
||||
3. **Respect platform conventions.** Length limits, formatting, link handling all differ.
|
||||
4. **One idea per post.** If the source content has multiple ideas, split across posts.
|
||||
5. **Attribution matters.** If crossposting someone else's content, credit the source.
|
||||
|
||||
## Platform Specifications
|
||||
|
||||
| Platform | Max Length | Link Handling | Hashtags | Media |
|
||||
|----------|-----------|---------------|----------|-------|
|
||||
| X | 280 chars (4000 for Premium) | Counted in length | Minimal (1-2 max) | Images, video, GIFs |
|
||||
| LinkedIn | 3000 chars | Not counted in length | 3-5 relevant | Images, video, docs, carousels |
|
||||
| Threads | 500 chars | Separate link attachment | None typical | Images, video |
|
||||
| Bluesky | 300 chars | Via facets (rich text) | None (use feeds) | Images |
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Create Source Content
|
||||
|
||||
Start with the core idea. Use `content-engine` skill for high-quality drafts:
|
||||
- Identify the single core message
|
||||
- Determine the primary platform (where the audience is biggest)
|
||||
- Draft the primary platform version first
|
||||
|
||||
### Step 2: Identify Target Platforms
|
||||
|
||||
Ask the user or determine from context:
|
||||
- Which platforms to target
|
||||
- Priority order (primary gets the best version)
|
||||
- Any platform-specific requirements (e.g., LinkedIn needs professional tone)
|
||||
|
||||
### Step 3: Adapt Per Platform
|
||||
|
||||
For each target platform, transform the content:
|
||||
|
||||
**X adaptation:**
|
||||
- Open with a hook, not a summary
|
||||
- Cut to the core insight fast
|
||||
- Keep links out of main body when possible
|
||||
- Use thread format for longer content
|
||||
|
||||
**LinkedIn adaptation:**
|
||||
- Strong first line (visible before "see more")
|
||||
- Short paragraphs with line breaks
|
||||
- Frame around lessons, results, or professional takeaways
|
||||
- More explicit context than X (LinkedIn audience needs framing)
|
||||
|
||||
**Threads adaptation:**
|
||||
- Conversational, casual tone
|
||||
- Shorter than LinkedIn, less compressed than X
|
||||
- Visual-first if possible
|
||||
|
||||
**Bluesky adaptation:**
|
||||
- Direct and concise (300 char limit)
|
||||
- Community-oriented tone
|
||||
- Use feeds/lists for topic targeting instead of hashtags
|
||||
|
||||
### Step 4: Post Primary Platform
|
||||
|
||||
Post to the primary platform first:
|
||||
- Use `x-api` skill for X
|
||||
- Use platform-specific APIs or tools for others
|
||||
- Capture the post URL for cross-referencing
|
||||
|
||||
### Step 5: Post to Secondary Platforms
|
||||
|
||||
Post adapted versions to remaining platforms:
|
||||
- Stagger timing (not all at once — 30-60 min gaps)
|
||||
- Include cross-platform references where appropriate ("longer thread on X" etc.)
|
||||
|
||||
## Content Adaptation Examples
|
||||
|
||||
### Source: Product Launch
|
||||
|
||||
**X version:**
|
||||
```
|
||||
We just shipped [feature].
|
||||
|
||||
[One specific thing it does that's impressive]
|
||||
|
||||
[Link]
|
||||
```
|
||||
|
||||
**LinkedIn version:**
|
||||
```
|
||||
Excited to share: we just launched [feature] at [Company].
|
||||
|
||||
Here's why it matters:
|
||||
|
||||
[2-3 short paragraphs with context]
|
||||
|
||||
[Takeaway for the audience]
|
||||
|
||||
[Link]
|
||||
```
|
||||
|
||||
**Threads version:**
|
||||
```
|
||||
just shipped something cool — [feature]
|
||||
|
||||
[casual explanation of what it does]
|
||||
|
||||
link in bio
|
||||
```
|
||||
|
||||
### Source: Technical Insight
|
||||
|
||||
**X version:**
|
||||
```
|
||||
TIL: [specific technical insight]
|
||||
|
||||
[Why it matters in one sentence]
|
||||
```
|
||||
|
||||
**LinkedIn version:**
|
||||
```
|
||||
A pattern I've been using that's made a real difference:
|
||||
|
||||
[Technical insight with professional framing]
|
||||
|
||||
[How it applies to teams/orgs]
|
||||
|
||||
#relevantHashtag
|
||||
```
|
||||
|
||||
## API Integration
|
||||
|
||||
### Batch Crossposting Service (Example Pattern)
|
||||
If using a crossposting service (e.g., Postbridge, Buffer, or a custom API), the pattern looks like:
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
resp = requests.post(
|
||||
"https://api.postbridge.io/v1/posts",
|
||||
headers={"Authorization": f"Bearer {os.environ['POSTBRIDGE_API_KEY']}"},
|
||||
json={
|
||||
"platforms": ["twitter", "linkedin", "threads"],
|
||||
"content": {
|
||||
"twitter": {"text": x_version},
|
||||
"linkedin": {"text": linkedin_version},
|
||||
"threads": {"text": threads_version}
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Manual Posting
|
||||
Without Postbridge, post to each platform using its native API:
|
||||
- X: Use `x-api` skill patterns
|
||||
- LinkedIn: LinkedIn API v2 with OAuth 2.0
|
||||
- Threads: Threads API (Meta)
|
||||
- Bluesky: AT Protocol API
|
||||
|
||||
## Quality Gate
|
||||
|
||||
Before posting:
|
||||
- [ ] Each platform version reads naturally for that platform
|
||||
- [ ] No identical content across platforms
|
||||
- [ ] Length limits respected
|
||||
- [ ] Links work and are placed appropriately
|
||||
- [ ] Tone matches platform conventions
|
||||
- [ ] Media is sized correctly for each platform
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `content-engine` — Generate platform-native content
|
||||
- `x-api` — X/Twitter API integration
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "Crosspost"
|
||||
short_description: "Multi-platform content distribution with native adaptation"
|
||||
brand_color: "#EC4899"
|
||||
default_prompt: "Distribute content across X, LinkedIn, Threads, and Bluesky with platform-native adaptation"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -1,155 +0,0 @@
|
||||
---
|
||||
name: deep-research
|
||||
description: Multi-source deep research using firecrawl and exa MCPs. Searches the web, synthesizes findings, and delivers cited reports with source attribution. Use when the user wants thorough research on any topic with evidence and citations.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Deep Research
|
||||
|
||||
Produce thorough, cited research reports from multiple web sources using firecrawl and exa MCP tools.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User asks to research any topic in depth
|
||||
- Competitive analysis, technology evaluation, or market sizing
|
||||
- Due diligence on companies, investors, or technologies
|
||||
- Any question requiring synthesis from multiple sources
|
||||
- User says "research", "deep dive", "investigate", or "what's the current state of"
|
||||
|
||||
## MCP Requirements
|
||||
|
||||
At least one of:
|
||||
- **firecrawl** — `firecrawl_search`, `firecrawl_scrape`, `firecrawl_crawl`
|
||||
- **exa** — `web_search_exa`, `web_search_advanced_exa`, `crawling_exa`
|
||||
|
||||
Both together give the best coverage. Configure in `~/.claude.json` or `~/.codex/config.toml`.
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Understand the Goal
|
||||
|
||||
Ask 1-2 quick clarifying questions:
|
||||
- "What's your goal — learning, making a decision, or writing something?"
|
||||
- "Any specific angle or depth you want?"
|
||||
|
||||
If the user says "just research it" — skip ahead with reasonable defaults.
|
||||
|
||||
### Step 2: Plan the Research
|
||||
|
||||
Break the topic into 3-5 research sub-questions. Example:
|
||||
- Topic: "Impact of AI on healthcare"
|
||||
- What are the main AI applications in healthcare today?
|
||||
- What clinical outcomes have been measured?
|
||||
- What are the regulatory challenges?
|
||||
- What companies are leading this space?
|
||||
- What's the market size and growth trajectory?
|
||||
|
||||
### Step 3: Execute Multi-Source Search
|
||||
|
||||
For EACH sub-question, search using available MCP tools:
|
||||
|
||||
**With firecrawl:**
|
||||
```
|
||||
firecrawl_search(query: "<sub-question keywords>", limit: 8)
|
||||
```
|
||||
|
||||
**With exa:**
|
||||
```
|
||||
web_search_exa(query: "<sub-question keywords>", numResults: 8)
|
||||
web_search_advanced_exa(query: "<keywords>", numResults: 5, startPublishedDate: "2025-01-01")
|
||||
```
|
||||
|
||||
**Search strategy:**
|
||||
- Use 2-3 different keyword variations per sub-question
|
||||
- Mix general and news-focused queries
|
||||
- Aim for 15-30 unique sources total
|
||||
- Prioritize: academic, official, reputable news > blogs > forums
|
||||
|
||||
### Step 4: Deep-Read Key Sources
|
||||
|
||||
For the most promising URLs, fetch full content:
|
||||
|
||||
**With firecrawl:**
|
||||
```
|
||||
firecrawl_scrape(url: "<url>")
|
||||
```
|
||||
|
||||
**With exa:**
|
||||
```
|
||||
crawling_exa(url: "<url>", tokensNum: 5000)
|
||||
```
|
||||
|
||||
Read 3-5 key sources in full for depth. Do not rely only on search snippets.
|
||||
|
||||
### Step 5: Synthesize and Write Report
|
||||
|
||||
Structure the report:
|
||||
|
||||
```markdown
|
||||
# [Topic]: Research Report
|
||||
*Generated: [date] | Sources: [N] | Confidence: [High/Medium/Low]*
|
||||
|
||||
## Executive Summary
|
||||
[3-5 sentence overview of key findings]
|
||||
|
||||
## 1. [First Major Theme]
|
||||
[Findings with inline citations]
|
||||
- Key point ([Source Name](url))
|
||||
- Supporting data ([Source Name](url))
|
||||
|
||||
## 2. [Second Major Theme]
|
||||
...
|
||||
|
||||
## 3. [Third Major Theme]
|
||||
...
|
||||
|
||||
## Key Takeaways
|
||||
- [Actionable insight 1]
|
||||
- [Actionable insight 2]
|
||||
- [Actionable insight 3]
|
||||
|
||||
## Sources
|
||||
1. [Title](url) — [one-line summary]
|
||||
2. ...
|
||||
|
||||
## Methodology
|
||||
Searched [N] queries across web and news. Analyzed [M] sources.
|
||||
Sub-questions investigated: [list]
|
||||
```
|
||||
|
||||
### Step 6: Deliver
|
||||
|
||||
- **Short topics**: Post the full report in chat
|
||||
- **Long reports**: Post the executive summary + key takeaways, save full report to a file
|
||||
|
||||
## Parallel Research with Subagents
|
||||
|
||||
For broad topics, use Claude Code's Task tool to parallelize:
|
||||
|
||||
```
|
||||
Launch 3 research agents in parallel:
|
||||
1. Agent 1: Research sub-questions 1-2
|
||||
2. Agent 2: Research sub-questions 3-4
|
||||
3. Agent 3: Research sub-question 5 + cross-cutting themes
|
||||
```
|
||||
|
||||
Each agent searches, reads sources, and returns findings. The main session synthesizes into the final report.
|
||||
|
||||
## Quality Rules
|
||||
|
||||
1. **Every claim needs a source.** No unsourced assertions.
|
||||
2. **Cross-reference.** If only one source says it, flag it as unverified.
|
||||
3. **Recency matters.** Prefer sources from the last 12 months.
|
||||
4. **Acknowledge gaps.** If you couldn't find good info on a sub-question, say so.
|
||||
5. **No hallucination.** If you don't know, say "insufficient data found."
|
||||
6. **Separate fact from inference.** Label estimates, projections, and opinions clearly.
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
"Research the current state of nuclear fusion energy"
|
||||
"Deep dive into Rust vs Go for backend services in 2026"
|
||||
"Research the best strategies for bootstrapping a SaaS business"
|
||||
"What's happening with the US housing market right now?"
|
||||
"Investigate the competitive landscape for AI code editors"
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "Deep Research"
|
||||
short_description: "Multi-source deep research with firecrawl and exa MCPs"
|
||||
brand_color: "#6366F1"
|
||||
default_prompt: "Research the given topic using firecrawl and exa, produce a cited report"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -1,144 +0,0 @@
|
||||
---
|
||||
name: dmux-workflows
|
||||
description: Multi-agent orchestration using dmux (tmux pane manager for AI agents). Patterns for parallel agent workflows across Claude Code, Codex, OpenCode, and other harnesses. Use when running multiple agent sessions in parallel or coordinating multi-agent development workflows.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# dmux Workflows
|
||||
|
||||
Orchestrate parallel AI agent sessions using dmux, a tmux pane manager for agent harnesses.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- Running multiple agent sessions in parallel
|
||||
- Coordinating work across Claude Code, Codex, and other harnesses
|
||||
- Complex tasks that benefit from divide-and-conquer parallelism
|
||||
- User says "run in parallel", "split this work", "use dmux", or "multi-agent"
|
||||
|
||||
## What is dmux
|
||||
|
||||
dmux is a tmux-based orchestration tool that manages AI agent panes:
|
||||
- Press `n` to create a new pane with a prompt
|
||||
- Press `m` to merge pane output back to the main session
|
||||
- Supports: Claude Code, Codex, OpenCode, Cline, Gemini, Qwen
|
||||
|
||||
**Install:** `npm install -g dmux` or see [github.com/standardagents/dmux](https://github.com/standardagents/dmux)
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Start dmux session
|
||||
dmux
|
||||
|
||||
# Create agent panes (press 'n' in dmux, then type prompt)
|
||||
# Pane 1: "Implement the auth middleware in src/auth/"
|
||||
# Pane 2: "Write tests for the user service"
|
||||
# Pane 3: "Update API documentation"
|
||||
|
||||
# Each pane runs its own agent session
|
||||
# Press 'm' to merge results back
|
||||
```
|
||||
|
||||
## Workflow Patterns
|
||||
|
||||
### Pattern 1: Research + Implement
|
||||
|
||||
Split research and implementation into parallel tracks:
|
||||
|
||||
```
|
||||
Pane 1 (Research): "Research best practices for rate limiting in Node.js.
|
||||
Check current libraries, compare approaches, and write findings to
|
||||
/tmp/rate-limit-research.md"
|
||||
|
||||
Pane 2 (Implement): "Implement rate limiting middleware for our Express API.
|
||||
Start with a basic token bucket, we'll refine after research completes."
|
||||
|
||||
# After Pane 1 completes, merge findings into Pane 2's context
|
||||
```
|
||||
|
||||
### Pattern 2: Multi-File Feature
|
||||
|
||||
Parallelize work across independent files:
|
||||
|
||||
```
|
||||
Pane 1: "Create the database schema and migrations for the billing feature"
|
||||
Pane 2: "Build the billing API endpoints in src/api/billing/"
|
||||
Pane 3: "Create the billing dashboard UI components"
|
||||
|
||||
# Merge all, then do integration in main pane
|
||||
```
|
||||
|
||||
### Pattern 3: Test + Fix Loop
|
||||
|
||||
Run tests in one pane, fix in another:
|
||||
|
||||
```
|
||||
Pane 1 (Watcher): "Run the test suite in watch mode. When tests fail,
|
||||
summarize the failures."
|
||||
|
||||
Pane 2 (Fixer): "Fix failing tests based on the error output from pane 1"
|
||||
```
|
||||
|
||||
### Pattern 4: Cross-Harness
|
||||
|
||||
Use different AI tools for different tasks:
|
||||
|
||||
```
|
||||
Pane 1 (Claude Code): "Review the security of the auth module"
|
||||
Pane 2 (Codex): "Refactor the utility functions for performance"
|
||||
Pane 3 (Claude Code): "Write E2E tests for the checkout flow"
|
||||
```
|
||||
|
||||
### Pattern 5: Code Review Pipeline
|
||||
|
||||
Parallel review perspectives:
|
||||
|
||||
```
|
||||
Pane 1: "Review src/api/ for security vulnerabilities"
|
||||
Pane 2: "Review src/api/ for performance issues"
|
||||
Pane 3: "Review src/api/ for test coverage gaps"
|
||||
|
||||
# Merge all reviews into a single report
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Independent tasks only.** Don't parallelize tasks that depend on each other's output.
|
||||
2. **Clear boundaries.** Each pane should work on distinct files or concerns.
|
||||
3. **Merge strategically.** Review pane output before merging to avoid conflicts.
|
||||
4. **Use git worktrees.** For file-conflict-prone work, use separate worktrees per pane.
|
||||
5. **Resource awareness.** Each pane uses API tokens — keep total panes under 5-6.
|
||||
|
||||
## Git Worktree Integration
|
||||
|
||||
For tasks that touch overlapping files:
|
||||
|
||||
```bash
|
||||
# Create worktrees for isolation
|
||||
git worktree add ../feature-auth feat/auth
|
||||
git worktree add ../feature-billing feat/billing
|
||||
|
||||
# Run agents in separate worktrees
|
||||
# Pane 1: cd ../feature-auth && claude
|
||||
# Pane 2: cd ../feature-billing && claude
|
||||
|
||||
# Merge branches when done
|
||||
git merge feat/auth
|
||||
git merge feat/billing
|
||||
```
|
||||
|
||||
## Complementary Tools
|
||||
|
||||
| Tool | What It Does | When to Use |
|
||||
|------|-------------|-------------|
|
||||
| **dmux** | tmux pane management for agents | Parallel agent sessions |
|
||||
| **Superset** | Terminal IDE for 10+ parallel agents | Large-scale orchestration |
|
||||
| **Claude Code Task tool** | In-process subagent spawning | Programmatic parallelism within a session |
|
||||
| **Codex multi-agent** | Built-in agent roles | Codex-specific parallel work |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **Pane not responding:** Check if the agent session is waiting for input. Use `m` to read output.
|
||||
- **Merge conflicts:** Use git worktrees to isolate file changes per pane.
|
||||
- **High token usage:** Reduce number of parallel panes. Each pane is a full agent session.
|
||||
- **tmux not found:** Install with `brew install tmux` (macOS) or `apt install tmux` (Linux).
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "dmux Workflows"
|
||||
short_description: "Multi-agent orchestration with dmux"
|
||||
brand_color: "#14B8A6"
|
||||
default_prompt: "Orchestrate parallel agent sessions using dmux pane manager"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -1,165 +0,0 @@
|
||||
---
|
||||
name: exa-search
|
||||
description: Neural search via Exa MCP for web, code, and company research. Use when the user needs web search, code examples, company intel, people lookup, or AI-powered deep research with Exa's neural search engine.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Exa Search
|
||||
|
||||
Neural search for web content, code, companies, and people via the Exa MCP server.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User needs current web information or news
|
||||
- Searching for code examples, API docs, or technical references
|
||||
- Researching companies, competitors, or market players
|
||||
- Finding professional profiles or people in a domain
|
||||
- Running background research for any development task
|
||||
- User says "search for", "look up", "find", or "what's the latest on"
|
||||
|
||||
## MCP Requirement
|
||||
|
||||
Exa MCP server must be configured. Add to `~/.claude.json`:
|
||||
|
||||
```json
|
||||
"exa-web-search": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "exa-mcp-server"],
|
||||
"env": { "EXA_API_KEY": "YOUR_EXA_API_KEY_HERE" }
|
||||
}
|
||||
```
|
||||
|
||||
Get an API key at [exa.ai](https://exa.ai).
|
||||
|
||||
## Core Tools
|
||||
|
||||
### web_search_exa
|
||||
General web search for current information, news, or facts.
|
||||
|
||||
```
|
||||
web_search_exa(query: "latest AI developments 2026", numResults: 5)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `query` | string | required | Search query |
|
||||
| `numResults` | number | 8 | Number of results |
|
||||
|
||||
### web_search_advanced_exa
|
||||
Filtered search with domain and date constraints.
|
||||
|
||||
```
|
||||
web_search_advanced_exa(
|
||||
query: "React Server Components best practices",
|
||||
numResults: 5,
|
||||
includeDomains: ["github.com", "react.dev"],
|
||||
startPublishedDate: "2025-01-01"
|
||||
)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `query` | string | required | Search query |
|
||||
| `numResults` | number | 8 | Number of results |
|
||||
| `includeDomains` | string[] | none | Limit to specific domains |
|
||||
| `excludeDomains` | string[] | none | Exclude specific domains |
|
||||
| `startPublishedDate` | string | none | ISO date filter (start) |
|
||||
| `endPublishedDate` | string | none | ISO date filter (end) |
|
||||
|
||||
### get_code_context_exa
|
||||
Find code examples and documentation from GitHub, Stack Overflow, and docs sites.
|
||||
|
||||
```
|
||||
get_code_context_exa(query: "Python asyncio patterns", tokensNum: 3000)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `query` | string | required | Code or API search query |
|
||||
| `tokensNum` | number | 5000 | Content tokens (1000-50000) |
|
||||
|
||||
### company_research_exa
|
||||
Research companies for business intelligence and news.
|
||||
|
||||
```
|
||||
company_research_exa(companyName: "Anthropic", numResults: 5)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `companyName` | string | required | Company name |
|
||||
| `numResults` | number | 5 | Number of results |
|
||||
|
||||
### people_search_exa
|
||||
Find professional profiles and bios.
|
||||
|
||||
```
|
||||
people_search_exa(query: "AI safety researchers at Anthropic", numResults: 5)
|
||||
```
|
||||
|
||||
### crawling_exa
|
||||
Extract full page content from a URL.
|
||||
|
||||
```
|
||||
crawling_exa(url: "https://example.com/article", tokensNum: 5000)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `url` | string | required | URL to extract |
|
||||
| `tokensNum` | number | 5000 | Content tokens |
|
||||
|
||||
### deep_researcher_start / deep_researcher_check
|
||||
Start an AI research agent that runs asynchronously.
|
||||
|
||||
```
|
||||
# Start research
|
||||
deep_researcher_start(query: "comprehensive analysis of AI code editors in 2026")
|
||||
|
||||
# Check status (returns results when complete)
|
||||
deep_researcher_check(researchId: "<id from start>")
|
||||
```
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
### Quick Lookup
|
||||
```
|
||||
web_search_exa(query: "Node.js 22 new features", numResults: 3)
|
||||
```
|
||||
|
||||
### Code Research
|
||||
```
|
||||
get_code_context_exa(query: "Rust error handling patterns Result type", tokensNum: 3000)
|
||||
```
|
||||
|
||||
### Company Due Diligence
|
||||
```
|
||||
company_research_exa(companyName: "Vercel", numResults: 5)
|
||||
web_search_advanced_exa(query: "Vercel funding valuation 2026", numResults: 3)
|
||||
```
|
||||
|
||||
### Technical Deep Dive
|
||||
```
|
||||
# Start async research
|
||||
deep_researcher_start(query: "WebAssembly component model status and adoption")
|
||||
# ... do other work ...
|
||||
deep_researcher_check(researchId: "<id>")
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Use `web_search_exa` for broad queries, `web_search_advanced_exa` for filtered results
|
||||
- Lower `tokensNum` (1000-2000) for focused code snippets, higher (5000+) for comprehensive context
|
||||
- Combine `company_research_exa` with `web_search_advanced_exa` for thorough company analysis
|
||||
- Use `crawling_exa` to get full content from specific URLs found in search results
|
||||
- `deep_researcher_start` is best for comprehensive topics that benefit from AI synthesis
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `deep-research` — Full research workflow using firecrawl + exa together
|
||||
- `market-research` — Business-oriented research with decision frameworks
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "Exa Search"
|
||||
short_description: "Neural search via Exa MCP for web, code, and companies"
|
||||
brand_color: "#8B5CF6"
|
||||
default_prompt: "Search using Exa MCP tools for web content, code, or company research"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -1,277 +0,0 @@
|
||||
---
|
||||
name: fal-ai-media
|
||||
description: Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# fal.ai Media Generation
|
||||
|
||||
Generate images, videos, and audio using fal.ai models via MCP.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to generate images from text prompts
|
||||
- Creating videos from text or images
|
||||
- Generating speech, music, or sound effects
|
||||
- Any media generation task
|
||||
- User says "generate image", "create video", "text to speech", "make a thumbnail", or similar
|
||||
|
||||
## MCP Requirement
|
||||
|
||||
fal.ai MCP server must be configured. Add to `~/.claude.json`:
|
||||
|
||||
```json
|
||||
"fal-ai": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "fal-ai-mcp-server"],
|
||||
"env": { "FAL_KEY": "YOUR_FAL_KEY_HERE" }
|
||||
}
|
||||
```
|
||||
|
||||
Get an API key at [fal.ai](https://fal.ai).
|
||||
|
||||
## MCP Tools
|
||||
|
||||
The fal.ai MCP provides these tools:
|
||||
- `search` — Find available models by keyword
|
||||
- `find` — Get model details and parameters
|
||||
- `generate` — Run a model with parameters
|
||||
- `result` — Check async generation status
|
||||
- `status` — Check job status
|
||||
- `cancel` — Cancel a running job
|
||||
- `estimate_cost` — Estimate generation cost
|
||||
- `models` — List popular models
|
||||
- `upload` — Upload files for use as inputs
|
||||
|
||||
---
|
||||
|
||||
## Image Generation
|
||||
|
||||
### Nano Banana 2 (Fast)
|
||||
Best for: quick iterations, drafts, text-to-image, image editing.
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/nano-banana-2",
|
||||
input: {
|
||||
"prompt": "a futuristic cityscape at sunset, cyberpunk style",
|
||||
"image_size": "landscape_16_9",
|
||||
"num_images": 1,
|
||||
"seed": 42
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Nano Banana Pro (High Fidelity)
|
||||
Best for: production images, realism, typography, detailed prompts.
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/nano-banana-pro",
|
||||
input: {
|
||||
"prompt": "professional product photo of wireless headphones on marble surface, studio lighting",
|
||||
"image_size": "square",
|
||||
"num_images": 1,
|
||||
"guidance_scale": 7.5
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Common Image Parameters
|
||||
|
||||
| Param | Type | Options | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `prompt` | string | required | Describe what you want |
|
||||
| `image_size` | string | `square`, `portrait_4_3`, `landscape_16_9`, `portrait_16_9`, `landscape_4_3` | Aspect ratio |
|
||||
| `num_images` | number | 1-4 | How many to generate |
|
||||
| `seed` | number | any integer | Reproducibility |
|
||||
| `guidance_scale` | number | 1-20 | How closely to follow the prompt (higher = more literal) |
|
||||
|
||||
### Image Editing
|
||||
Use Nano Banana 2 with an input image for inpainting, outpainting, or style transfer:
|
||||
|
||||
```
|
||||
# First upload the source image
|
||||
upload(file_path: "/path/to/image.png")
|
||||
|
||||
# Then generate with image input
|
||||
generate(
|
||||
model_name: "fal-ai/nano-banana-2",
|
||||
input: {
|
||||
"prompt": "same scene but in watercolor style",
|
||||
"image_url": "<uploaded_url>",
|
||||
"image_size": "landscape_16_9"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Video Generation
|
||||
|
||||
### Seedance 1.0 Pro (ByteDance)
|
||||
Best for: text-to-video, image-to-video with high motion quality.
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/seedance-1-0-pro",
|
||||
input: {
|
||||
"prompt": "a drone flyover of a mountain lake at golden hour, cinematic",
|
||||
"duration": "5s",
|
||||
"aspect_ratio": "16:9",
|
||||
"seed": 42
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Kling Video v3 Pro
|
||||
Best for: text/image-to-video with native audio generation.
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/kling-video/v3/pro",
|
||||
input: {
|
||||
"prompt": "ocean waves crashing on a rocky coast, dramatic clouds",
|
||||
"duration": "5s",
|
||||
"aspect_ratio": "16:9"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Veo 3 (Google DeepMind)
|
||||
Best for: video with generated sound, high visual quality.
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/veo-3",
|
||||
input: {
|
||||
"prompt": "a bustling Tokyo street market at night, neon signs, crowd noise",
|
||||
"aspect_ratio": "16:9"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Image-to-Video
|
||||
Start from an existing image:
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/seedance-1-0-pro",
|
||||
input: {
|
||||
"prompt": "camera slowly zooms out, gentle wind moves the trees",
|
||||
"image_url": "<uploaded_image_url>",
|
||||
"duration": "5s"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Video Parameters
|
||||
|
||||
| Param | Type | Options | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `prompt` | string | required | Describe the video |
|
||||
| `duration` | string | `"5s"`, `"10s"` | Video length |
|
||||
| `aspect_ratio` | string | `"16:9"`, `"9:16"`, `"1:1"` | Frame ratio |
|
||||
| `seed` | number | any integer | Reproducibility |
|
||||
| `image_url` | string | URL | Source image for image-to-video |
|
||||
|
||||
---
|
||||
|
||||
## Audio Generation
|
||||
|
||||
### CSM-1B (Conversational Speech)
|
||||
Text-to-speech with natural, conversational quality.
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/csm-1b",
|
||||
input: {
|
||||
"text": "Hello, welcome to the demo. Let me show you how this works.",
|
||||
"speaker_id": 0
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### ThinkSound (Video-to-Audio)
|
||||
Generate matching audio from video content.
|
||||
|
||||
```
|
||||
generate(
|
||||
model_name: "fal-ai/thinksound",
|
||||
input: {
|
||||
"video_url": "<video_url>",
|
||||
"prompt": "ambient forest sounds with birds chirping"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### ElevenLabs (via API, no MCP)
|
||||
For professional voice synthesis, use ElevenLabs directly:
|
||||
|
||||
```python
|
||||
import os
|
||||
import requests
|
||||
|
||||
resp = requests.post(
|
||||
"https://api.elevenlabs.io/v1/text-to-speech/<voice_id>",
|
||||
headers={
|
||||
"xi-api-key": os.environ["ELEVENLABS_API_KEY"],
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
json={
|
||||
"text": "Your text here",
|
||||
"model_id": "eleven_turbo_v2_5",
|
||||
"voice_settings": {"stability": 0.5, "similarity_boost": 0.75}
|
||||
}
|
||||
)
|
||||
with open("output.mp3", "wb") as f:
|
||||
f.write(resp.content)
|
||||
```
|
||||
|
||||
### VideoDB Generative Audio
|
||||
If VideoDB is configured, use its generative audio:
|
||||
|
||||
```python
|
||||
# Voice generation
|
||||
audio = coll.generate_voice(text="Your narration here", voice="alloy")
|
||||
|
||||
# Music generation
|
||||
music = coll.generate_music(prompt="upbeat electronic background music", duration=30)
|
||||
|
||||
# Sound effects
|
||||
sfx = coll.generate_sound_effect(prompt="thunder crack followed by rain")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cost Estimation
|
||||
|
||||
Before generating, check estimated cost:
|
||||
|
||||
```
|
||||
estimate_cost(model_name: "fal-ai/nano-banana-pro", input: {...})
|
||||
```
|
||||
|
||||
## Model Discovery
|
||||
|
||||
Find models for specific tasks:
|
||||
|
||||
```
|
||||
search(query: "text to video")
|
||||
find(model_name: "fal-ai/seedance-1-0-pro")
|
||||
models()
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Use `seed` for reproducible results when iterating on prompts
|
||||
- Start with lower-cost models (Nano Banana 2) for prompt iteration, then switch to Pro for finals
|
||||
- For video, keep prompts descriptive but concise — focus on motion and scene
|
||||
- Image-to-video produces more controlled results than pure text-to-video
|
||||
- Check `estimate_cost` before running expensive video generations
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `videodb` — Video processing, editing, and streaming
|
||||
- `video-editing` — AI-powered video editing workflows
|
||||
- `content-engine` — Content creation for social platforms
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "fal.ai Media"
|
||||
short_description: "AI image, video, and audio generation via fal.ai"
|
||||
brand_color: "#F43F5E"
|
||||
default_prompt: "Generate images, videos, or audio using fal.ai models"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -1,308 +0,0 @@
|
||||
---
|
||||
name: video-editing
|
||||
description: AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Video Editing
|
||||
|
||||
AI-assisted editing for real footage. Not generation from prompts. Editing existing video fast.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to edit, cut, or structure video footage
|
||||
- Turning long recordings into short-form content
|
||||
- Building vlogs, tutorials, or demo videos from raw capture
|
||||
- Adding overlays, subtitles, music, or voiceover to existing video
|
||||
- Reframing video for different platforms (YouTube, TikTok, Instagram)
|
||||
- User says "edit video", "cut this footage", "make a vlog", or "video workflow"
|
||||
|
||||
## Core Thesis
|
||||
|
||||
AI video editing is useful when you stop asking it to create the whole video and start using it to compress, structure, and augment real footage. The value is not generation. The value is compression.
|
||||
|
||||
## The Pipeline
|
||||
|
||||
```
|
||||
Screen Studio / raw footage
|
||||
→ Claude / Codex
|
||||
→ FFmpeg
|
||||
→ Remotion
|
||||
→ ElevenLabs / fal.ai
|
||||
→ Descript or CapCut
|
||||
```
|
||||
|
||||
Each layer has a specific job. Do not skip layers. Do not try to make one tool do everything.
|
||||
|
||||
## Layer 1: Capture (Screen Studio / Raw Footage)
|
||||
|
||||
Collect the source material:
|
||||
- **Screen Studio**: polished screen recordings for app demos, coding sessions, browser workflows
|
||||
- **Raw camera footage**: vlog footage, interviews, event recordings
|
||||
- **Desktop capture via VideoDB**: session recording with real-time context (see `videodb` skill)
|
||||
|
||||
Output: raw files ready for organization.
|
||||
|
||||
## Layer 2: Organization (Claude / Codex)
|
||||
|
||||
Use Claude Code or Codex to:
|
||||
- **Transcribe and label**: generate transcript, identify topics and themes
|
||||
- **Plan structure**: decide what stays, what gets cut, what order works
|
||||
- **Identify dead sections**: find pauses, tangents, repeated takes
|
||||
- **Generate edit decision list**: timestamps for cuts, segments to keep
|
||||
- **Scaffold FFmpeg and Remotion code**: generate the commands and compositions
|
||||
|
||||
```
|
||||
Example prompt:
|
||||
"Here's the transcript of a 4-hour recording. Identify the 8 strongest segments
|
||||
for a 24-minute vlog. Give me FFmpeg cut commands for each segment."
|
||||
```
|
||||
|
||||
This layer is about structure, not final creative taste.
|
||||
|
||||
## Layer 3: Deterministic Cuts (FFmpeg)
|
||||
|
||||
FFmpeg handles the boring but critical work: splitting, trimming, concatenating, and preprocessing.
|
||||
|
||||
### Extract segment by timestamp
|
||||
|
||||
```bash
|
||||
ffmpeg -i raw.mp4 -ss 00:12:30 -to 00:15:45 -c copy segment_01.mp4
|
||||
```
|
||||
|
||||
### Batch cut from edit decision list
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# cuts.txt: start,end,label
|
||||
while IFS=, read -r start end label; do
|
||||
ffmpeg -i raw.mp4 -ss "$start" -to "$end" -c copy "segments/${label}.mp4"
|
||||
done < cuts.txt
|
||||
```
|
||||
|
||||
### Concatenate segments
|
||||
|
||||
```bash
|
||||
# Create file list
|
||||
for f in segments/*.mp4; do echo "file '$f'"; done > concat.txt
|
||||
ffmpeg -f concat -safe 0 -i concat.txt -c copy assembled.mp4
|
||||
```
|
||||
|
||||
### Create proxy for faster editing
|
||||
|
||||
```bash
|
||||
ffmpeg -i raw.mp4 -vf "scale=960:-2" -c:v libx264 -preset ultrafast -crf 28 proxy.mp4
|
||||
```
|
||||
|
||||
### Extract audio for transcription
|
||||
|
||||
```bash
|
||||
ffmpeg -i raw.mp4 -vn -acodec pcm_s16le -ar 16000 audio.wav
|
||||
```
|
||||
|
||||
### Normalize audio levels
|
||||
|
||||
```bash
|
||||
ffmpeg -i segment.mp4 -af loudnorm=I=-16:TP=-1.5:LRA=11 -c:v copy normalized.mp4
|
||||
```
|
||||
|
||||
## Layer 4: Programmable Composition (Remotion)
|
||||
|
||||
Remotion turns editing problems into composable code. Use it for things that traditional editors make painful:
|
||||
|
||||
### When to use Remotion
|
||||
|
||||
- Overlays: text, images, branding, lower thirds
|
||||
- Data visualizations: charts, stats, animated numbers
|
||||
- Motion graphics: transitions, explainer animations
|
||||
- Composable scenes: reusable templates across videos
|
||||
- Product demos: annotated screenshots, UI highlights
|
||||
|
||||
### Basic Remotion composition
|
||||
|
||||
```tsx
|
||||
import { AbsoluteFill, Sequence, Video, useCurrentFrame } from "remotion";
|
||||
|
||||
export const VlogComposition: React.FC = () => {
|
||||
const frame = useCurrentFrame();
|
||||
|
||||
return (
|
||||
<AbsoluteFill>
|
||||
{/* Main footage */}
|
||||
<Sequence from={0} durationInFrames={300}>
|
||||
<Video src="/segments/intro.mp4" />
|
||||
</Sequence>
|
||||
|
||||
{/* Title overlay */}
|
||||
<Sequence from={30} durationInFrames={90}>
|
||||
<AbsoluteFill style={{
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: 72,
|
||||
color: "white",
|
||||
textShadow: "2px 2px 8px rgba(0,0,0,0.8)",
|
||||
}}>
|
||||
The AI Editing Stack
|
||||
</h1>
|
||||
</AbsoluteFill>
|
||||
</Sequence>
|
||||
|
||||
{/* Next segment */}
|
||||
<Sequence from={300} durationInFrames={450}>
|
||||
<Video src="/segments/demo.mp4" />
|
||||
</Sequence>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### Render output
|
||||
|
||||
```bash
|
||||
npx remotion render src/index.ts VlogComposition output.mp4
|
||||
```
|
||||
|
||||
See the [Remotion docs](https://www.remotion.dev/docs) for detailed patterns and API reference.
|
||||
|
||||
## Layer 5: Generated Assets (ElevenLabs / fal.ai)
|
||||
|
||||
Generate only what you need. Do not generate the whole video.
|
||||
|
||||
### Voiceover with ElevenLabs
|
||||
|
||||
```python
|
||||
import os
|
||||
import requests
|
||||
|
||||
resp = requests.post(
|
||||
f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
|
||||
headers={
|
||||
"xi-api-key": os.environ["ELEVENLABS_API_KEY"],
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
json={
|
||||
"text": "Your narration text here",
|
||||
"model_id": "eleven_turbo_v2_5",
|
||||
"voice_settings": {"stability": 0.5, "similarity_boost": 0.75}
|
||||
}
|
||||
)
|
||||
with open("voiceover.mp3", "wb") as f:
|
||||
f.write(resp.content)
|
||||
```
|
||||
|
||||
### Music and SFX with fal.ai
|
||||
|
||||
Use the `fal-ai-media` skill for:
|
||||
- Background music generation
|
||||
- Sound effects (ThinkSound model for video-to-audio)
|
||||
- Transition sounds
|
||||
|
||||
### Generated visuals with fal.ai
|
||||
|
||||
Use for insert shots, thumbnails, or b-roll that doesn't exist:
|
||||
```
|
||||
generate(model_name: "fal-ai/nano-banana-pro", input: {
|
||||
"prompt": "professional thumbnail for tech vlog, dark background, code on screen",
|
||||
"image_size": "landscape_16_9"
|
||||
})
|
||||
```
|
||||
|
||||
### VideoDB generative audio
|
||||
|
||||
If VideoDB is configured:
|
||||
```python
|
||||
voiceover = coll.generate_voice(text="Narration here", voice="alloy")
|
||||
music = coll.generate_music(prompt="lo-fi background for coding vlog", duration=120)
|
||||
sfx = coll.generate_sound_effect(prompt="subtle whoosh transition")
|
||||
```
|
||||
|
||||
## Layer 6: Final Polish (Descript / CapCut)
|
||||
|
||||
The last layer is human. Use a traditional editor for:
|
||||
- **Pacing**: adjust cuts that feel too fast or slow
|
||||
- **Captions**: auto-generated, then manually cleaned
|
||||
- **Color grading**: basic correction and mood
|
||||
- **Final audio mix**: balance voice, music, and SFX levels
|
||||
- **Export**: platform-specific formats and quality settings
|
||||
|
||||
This is where taste lives. AI clears the repetitive work. You make the final calls.
|
||||
|
||||
## Social Media Reframing
|
||||
|
||||
Different platforms need different aspect ratios:
|
||||
|
||||
| Platform | Aspect Ratio | Resolution |
|
||||
|----------|-------------|------------|
|
||||
| YouTube | 16:9 | 1920x1080 |
|
||||
| TikTok / Reels | 9:16 | 1080x1920 |
|
||||
| Instagram Feed | 1:1 | 1080x1080 |
|
||||
| X / Twitter | 16:9 or 1:1 | 1280x720 or 720x720 |
|
||||
|
||||
### Reframe with FFmpeg
|
||||
|
||||
```bash
|
||||
# 16:9 to 9:16 (center crop)
|
||||
ffmpeg -i input.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920" vertical.mp4
|
||||
|
||||
# 16:9 to 1:1 (center crop)
|
||||
ffmpeg -i input.mp4 -vf "crop=ih:ih,scale=1080:1080" square.mp4
|
||||
```
|
||||
|
||||
### Reframe with VideoDB
|
||||
|
||||
```python
|
||||
# Smart reframe (AI-guided subject tracking)
|
||||
reframed = video.reframe(start=0, end=60, target="vertical", mode=ReframeMode.smart)
|
||||
```
|
||||
|
||||
## Scene Detection and Auto-Cut
|
||||
|
||||
### FFmpeg scene detection
|
||||
|
||||
```bash
|
||||
# Detect scene changes (threshold 0.3 = moderate sensitivity)
|
||||
ffmpeg -i input.mp4 -vf "select='gt(scene,0.3)',showinfo" -vsync vfr -f null - 2>&1 | grep showinfo
|
||||
```
|
||||
|
||||
### Silence detection for auto-cut
|
||||
|
||||
```bash
|
||||
# Find silent segments (useful for cutting dead air)
|
||||
ffmpeg -i input.mp4 -af silencedetect=noise=-30dB:d=2 -f null - 2>&1 | grep silence
|
||||
```
|
||||
|
||||
### Highlight extraction
|
||||
|
||||
Use Claude to analyze transcript + scene timestamps:
|
||||
```
|
||||
"Given this transcript with timestamps and these scene change points,
|
||||
identify the 5 most engaging 30-second clips for social media."
|
||||
```
|
||||
|
||||
## What Each Tool Does Best
|
||||
|
||||
| Tool | Strength | Weakness |
|
||||
|------|----------|----------|
|
||||
| Claude / Codex | Organization, planning, code generation | Not the creative taste layer |
|
||||
| FFmpeg | Deterministic cuts, batch processing, format conversion | No visual editing UI |
|
||||
| Remotion | Programmable overlays, composable scenes, reusable templates | Learning curve for non-devs |
|
||||
| Screen Studio | Polished screen recordings immediately | Only screen capture |
|
||||
| ElevenLabs | Voice, narration, music, SFX | Not the center of the workflow |
|
||||
| Descript / CapCut | Final pacing, captions, polish | Manual, not automatable |
|
||||
|
||||
## Key Principles
|
||||
|
||||
1. **Edit, don't generate.** This workflow is for cutting real footage, not creating from prompts.
|
||||
2. **Structure before style.** Get the story right in Layer 2 before touching anything visual.
|
||||
3. **FFmpeg is the backbone.** Boring but critical. Where long footage becomes manageable.
|
||||
4. **Remotion for repeatability.** If you'll do it more than once, make it a Remotion component.
|
||||
5. **Generate selectively.** Only use AI generation for assets that don't exist, not for everything.
|
||||
6. **Taste is the last layer.** AI clears repetitive work. You make the final creative calls.
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `fal-ai-media` — AI image, video, and audio generation
|
||||
- `videodb` — Server-side video processing, indexing, and streaming
|
||||
- `content-engine` — Platform-native content distribution
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "Video Editing"
|
||||
short_description: "AI-assisted video editing for real footage"
|
||||
brand_color: "#EF4444"
|
||||
default_prompt: "Edit video using AI-assisted pipeline: organize, cut, compose, generate assets, polish"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -1,211 +0,0 @@
|
||||
---
|
||||
name: x-api
|
||||
description: X/Twitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# X API
|
||||
|
||||
Programmatic interaction with X (Twitter) for posting, reading, searching, and analytics.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to post tweets or threads programmatically
|
||||
- Reading timeline, mentions, or user data from X
|
||||
- Searching X for content, trends, or conversations
|
||||
- Building X integrations or bots
|
||||
- Analytics and engagement tracking
|
||||
- User says "post to X", "tweet", "X API", or "Twitter API"
|
||||
|
||||
## Authentication
|
||||
|
||||
### OAuth 2.0 (App-Only / User Context)
|
||||
|
||||
Best for: read-heavy operations, search, public data.
|
||||
|
||||
```bash
|
||||
# Environment setup
|
||||
export X_BEARER_TOKEN="your-bearer-token"
|
||||
```
|
||||
|
||||
```python
|
||||
import os
|
||||
import requests
|
||||
|
||||
bearer = os.environ["X_BEARER_TOKEN"]
|
||||
headers = {"Authorization": f"Bearer {bearer}"}
|
||||
|
||||
# Search recent tweets
|
||||
resp = requests.get(
|
||||
"https://api.x.com/2/tweets/search/recent",
|
||||
headers=headers,
|
||||
params={"query": "claude code", "max_results": 10}
|
||||
)
|
||||
tweets = resp.json()
|
||||
```
|
||||
|
||||
### OAuth 1.0a (User Context)
|
||||
|
||||
Required for: posting tweets, managing account, DMs.
|
||||
|
||||
```bash
|
||||
# Environment setup — source before use
|
||||
export X_API_KEY="your-api-key"
|
||||
export X_API_SECRET="your-api-secret"
|
||||
export X_ACCESS_TOKEN="your-access-token"
|
||||
export X_ACCESS_SECRET="your-access-secret"
|
||||
```
|
||||
|
||||
```python
|
||||
import os
|
||||
from requests_oauthlib import OAuth1Session
|
||||
|
||||
oauth = OAuth1Session(
|
||||
os.environ["X_API_KEY"],
|
||||
client_secret=os.environ["X_API_SECRET"],
|
||||
resource_owner_key=os.environ["X_ACCESS_TOKEN"],
|
||||
resource_owner_secret=os.environ["X_ACCESS_SECRET"],
|
||||
)
|
||||
```
|
||||
|
||||
## Core Operations
|
||||
|
||||
### Post a Tweet
|
||||
|
||||
```python
|
||||
resp = oauth.post(
|
||||
"https://api.x.com/2/tweets",
|
||||
json={"text": "Hello from Claude Code"}
|
||||
)
|
||||
resp.raise_for_status()
|
||||
tweet_id = resp.json()["data"]["id"]
|
||||
```
|
||||
|
||||
### Post a Thread
|
||||
|
||||
```python
|
||||
def post_thread(oauth, tweets: list[str]) -> list[str]:
|
||||
ids = []
|
||||
reply_to = None
|
||||
for text in tweets:
|
||||
payload = {"text": text}
|
||||
if reply_to:
|
||||
payload["reply"] = {"in_reply_to_tweet_id": reply_to}
|
||||
resp = oauth.post("https://api.x.com/2/tweets", json=payload)
|
||||
tweet_id = resp.json()["data"]["id"]
|
||||
ids.append(tweet_id)
|
||||
reply_to = tweet_id
|
||||
return ids
|
||||
```
|
||||
|
||||
### Read User Timeline
|
||||
|
||||
```python
|
||||
resp = requests.get(
|
||||
f"https://api.x.com/2/users/{user_id}/tweets",
|
||||
headers=headers,
|
||||
params={
|
||||
"max_results": 10,
|
||||
"tweet.fields": "created_at,public_metrics",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Search Tweets
|
||||
|
||||
```python
|
||||
resp = requests.get(
|
||||
"https://api.x.com/2/tweets/search/recent",
|
||||
headers=headers,
|
||||
params={
|
||||
"query": "from:affaanmustafa -is:retweet",
|
||||
"max_results": 10,
|
||||
"tweet.fields": "public_metrics,created_at",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Get User by Username
|
||||
|
||||
```python
|
||||
resp = requests.get(
|
||||
"https://api.x.com/2/users/by/username/affaanmustafa",
|
||||
headers=headers,
|
||||
params={"user.fields": "public_metrics,description,created_at"}
|
||||
)
|
||||
```
|
||||
|
||||
### Upload Media and Post
|
||||
|
||||
```python
|
||||
# Media upload uses v1.1 endpoint
|
||||
|
||||
# Step 1: Upload media
|
||||
media_resp = oauth.post(
|
||||
"https://upload.twitter.com/1.1/media/upload.json",
|
||||
files={"media": open("image.png", "rb")}
|
||||
)
|
||||
media_id = media_resp.json()["media_id_string"]
|
||||
|
||||
# Step 2: Post with media
|
||||
resp = oauth.post(
|
||||
"https://api.x.com/2/tweets",
|
||||
json={"text": "Check this out", "media": {"media_ids": [media_id]}}
|
||||
)
|
||||
```
|
||||
|
||||
## Rate Limits Reference
|
||||
|
||||
| Endpoint | Limit | Window |
|
||||
|----------|-------|--------|
|
||||
| POST /2/tweets | 200 | 15 min |
|
||||
| GET /2/tweets/search/recent | 450 | 15 min |
|
||||
| GET /2/users/:id/tweets | 1500 | 15 min |
|
||||
| GET /2/users/by/username | 300 | 15 min |
|
||||
| POST media/upload | 415 | 15 min |
|
||||
|
||||
Always check `x-rate-limit-remaining` and `x-rate-limit-reset` headers.
|
||||
|
||||
```python
|
||||
remaining = int(resp.headers.get("x-rate-limit-remaining", 0))
|
||||
if remaining < 5:
|
||||
reset = int(resp.headers.get("x-rate-limit-reset", 0))
|
||||
wait = max(0, reset - int(time.time()))
|
||||
print(f"Rate limit approaching. Resets in {wait}s")
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```python
|
||||
resp = oauth.post("https://api.x.com/2/tweets", json={"text": content})
|
||||
if resp.status_code == 201:
|
||||
return resp.json()["data"]["id"]
|
||||
elif resp.status_code == 429:
|
||||
reset = int(resp.headers["x-rate-limit-reset"])
|
||||
raise Exception(f"Rate limited. Resets at {reset}")
|
||||
elif resp.status_code == 403:
|
||||
raise Exception(f"Forbidden: {resp.json().get('detail', 'check permissions')}")
|
||||
else:
|
||||
raise Exception(f"X API error {resp.status_code}: {resp.text}")
|
||||
```
|
||||
|
||||
## Security
|
||||
|
||||
- **Never hardcode tokens.** Use environment variables or `.env` files.
|
||||
- **Never commit `.env` files.** Add to `.gitignore`.
|
||||
- **Rotate tokens** if exposed. Regenerate at developer.x.com.
|
||||
- **Use read-only tokens** when write access is not needed.
|
||||
- **Store OAuth secrets securely** — not in source code or logs.
|
||||
|
||||
## Integration with Content Engine
|
||||
|
||||
Use `content-engine` skill to generate platform-native content, then post via X API:
|
||||
1. Generate content with content-engine (X platform format)
|
||||
2. Validate length (280 chars for single tweet)
|
||||
3. Post via X API using patterns above
|
||||
4. Track engagement via public_metrics
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `content-engine` — Generate platform-native content for X
|
||||
- `crosspost` — Distribute content across X, LinkedIn, and other platforms
|
||||
@@ -1,7 +0,0 @@
|
||||
interface:
|
||||
display_name: "X API"
|
||||
short_description: "X/Twitter API integration for posting, threads, and analytics"
|
||||
brand_color: "#000000"
|
||||
default_prompt: "Use X API to post tweets, threads, or retrieve timeline and search data"
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -34,17 +34,10 @@ Available skills:
|
||||
- strategic-compact — Context management
|
||||
- api-design — REST API design patterns
|
||||
- verification-loop — Build, test, lint, typecheck, security
|
||||
- deep-research — Multi-source research with firecrawl and exa MCPs
|
||||
- exa-search — Neural search via Exa MCP for web, code, and companies
|
||||
- claude-api — Anthropic Claude API patterns and SDKs
|
||||
- x-api — X/Twitter API integration for posting, threads, and analytics
|
||||
- crosspost — Multi-platform content distribution
|
||||
- fal-ai-media — AI image/video/audio generation via fal.ai
|
||||
- dmux-workflows — Multi-agent orchestration with dmux
|
||||
|
||||
## MCP Servers
|
||||
|
||||
Treat the project-local `.codex/config.toml` as the default Codex baseline for ECC. The current ECC baseline enables GitHub, Context7, Exa, Memory, Playwright, and Sequential Thinking; add heavier extras in `~/.codex/config.toml` only when a task actually needs them.
|
||||
Configure in `~/.codex/config.toml` under `[mcp_servers]`. See `.codex/config.toml` for reference configuration with GitHub, Context7, Memory, and Sequential Thinking servers.
|
||||
|
||||
## Multi-Agent Support
|
||||
|
||||
@@ -70,7 +63,7 @@ Sample role configs in this repo:
|
||||
| Commands | `/slash` commands | Instruction-based |
|
||||
| Agents | Subagent Task tool | Multi-agent via `/agent` and `[agents.<name>]` roles |
|
||||
| Security | Hook-based enforcement | Instruction + sandbox |
|
||||
| MCP | Full support | Supported via `config.toml` and `codex mcp add` |
|
||||
| MCP | Full support | Command-based only |
|
||||
|
||||
## Security Without Hooks
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ notify = [
|
||||
# model_instructions_file = "/absolute/path/to/instructions.md"
|
||||
|
||||
# MCP servers
|
||||
# Keep the default project set lean. API-backed servers inherit credentials from
|
||||
# the launching environment or can be supplied by a user-level ~/.codex/config.toml.
|
||||
[mcp_servers.github]
|
||||
command = "npx"
|
||||
args = ["-y", "@modelcontextprotocol/server-github"]
|
||||
@@ -43,17 +41,10 @@ args = ["-y", "@modelcontextprotocol/server-github"]
|
||||
command = "npx"
|
||||
args = ["-y", "@upstash/context7-mcp@latest"]
|
||||
|
||||
[mcp_servers.exa]
|
||||
url = "https://mcp.exa.ai/mcp"
|
||||
|
||||
[mcp_servers.memory]
|
||||
command = "npx"
|
||||
args = ["-y", "@modelcontextprotocol/server-memory"]
|
||||
|
||||
[mcp_servers.playwright]
|
||||
command = "npx"
|
||||
args = ["-y", "@playwright/mcp@latest", "--extension"]
|
||||
|
||||
[mcp_servers.sequential-thinking]
|
||||
command = "npx"
|
||||
args = ["-y", "@modelcontextprotocol/server-sequential-thinking"]
|
||||
@@ -67,10 +58,6 @@ args = ["-y", "@modelcontextprotocol/server-sequential-thinking"]
|
||||
# command = "npx"
|
||||
# args = ["-y", "firecrawl-mcp"]
|
||||
#
|
||||
# [mcp_servers.fal-ai]
|
||||
# command = "npx"
|
||||
# args = ["-y", "fal-ai-mcp-server"]
|
||||
#
|
||||
# [mcp_servers.cloudflare]
|
||||
# command = "npx"
|
||||
# args = ["-y", "@cloudflare/mcp-server-cloudflare"]
|
||||
@@ -90,18 +77,22 @@ approval_policy = "never"
|
||||
sandbox_mode = "workspace-write"
|
||||
web_search = "live"
|
||||
|
||||
[agents]
|
||||
max_threads = 6
|
||||
max_depth = 1
|
||||
|
||||
[agents.explorer]
|
||||
description = "Read-only codebase explorer for gathering evidence before changes are proposed."
|
||||
config_file = "agents/explorer.toml"
|
||||
|
||||
[agents.reviewer]
|
||||
description = "PR reviewer focused on correctness, security, and missing tests."
|
||||
config_file = "agents/reviewer.toml"
|
||||
|
||||
[agents.docs_researcher]
|
||||
description = "Documentation specialist that verifies APIs, framework behavior, and release notes."
|
||||
config_file = "agents/docs-researcher.toml"
|
||||
# Optional project-local multi-agent roles.
|
||||
# Keep these commented in global config, because config_file paths are resolved
|
||||
# relative to the config.toml file and must exist at load time.
|
||||
#
|
||||
# [agents]
|
||||
# max_threads = 6
|
||||
# max_depth = 1
|
||||
#
|
||||
# [agents.explorer]
|
||||
# description = "Read-only codebase explorer for gathering evidence before changes are proposed."
|
||||
# config_file = "agents/explorer.toml"
|
||||
#
|
||||
# [agents.reviewer]
|
||||
# description = "PR reviewer focused on correctness, security, and missing tests."
|
||||
# config_file = "agents/reviewer.toml"
|
||||
#
|
||||
# [agents.docs_researcher]
|
||||
# description = "Documentation specialist that verifies APIs, framework behavior, and release notes."
|
||||
# config_file = "agents/docs-researcher.toml"
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -41,4 +41,3 @@ examples/sessions/*.tmp
|
||||
|
||||
# Local drafts
|
||||
marketing/
|
||||
.dmux/
|
||||
|
||||
@@ -101,14 +101,6 @@ TaskOutput({ task_id: "<task_id>", block: true, timeout: 600000 })
|
||||
4. Force stop when score < 7 or user does not approve.
|
||||
5. Use `AskUserQuestion` tool for user interaction when needed (e.g., confirmation/selection/approval).
|
||||
|
||||
## When to Use External Orchestration
|
||||
|
||||
Use external tmux/worktree orchestration when the work must be split across parallel workers that need isolated git state, independent terminals, or separate build/test execution. Use in-process subagents for lightweight analysis, planning, or review where the main session remains the only writer.
|
||||
|
||||
```bash
|
||||
node scripts/orchestrate-worktrees.js .claude/plan/workflow-e2e-test.json --execute
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Workflow
|
||||
|
||||
@@ -148,61 +148,6 @@ Run simultaneously:
|
||||
Combine outputs into single report
|
||||
```
|
||||
|
||||
For external tmux-pane workers with separate git worktrees, use `node scripts/orchestrate-worktrees.js plan.json --execute`. The built-in orchestration pattern stays in-process; the helper is for long-running or cross-harness sessions.
|
||||
|
||||
When workers need to see dirty or untracked local files from the main checkout, add `seedPaths` to the plan file. ECC overlays only those selected paths into each worker worktree after `git worktree add`, which keeps the branch isolated while still exposing in-flight local scripts, plans, or docs.
|
||||
|
||||
```json
|
||||
{
|
||||
"sessionName": "workflow-e2e",
|
||||
"seedPaths": [
|
||||
"scripts/orchestrate-worktrees.js",
|
||||
"scripts/lib/tmux-worktree-orchestrator.js",
|
||||
".claude/plan/workflow-e2e-test.json"
|
||||
],
|
||||
"workers": [
|
||||
{ "name": "docs", "task": "Update orchestration docs." }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
To export a control-plane snapshot for a live tmux/worktree session, run:
|
||||
|
||||
```bash
|
||||
node scripts/orchestration-status.js .claude/plan/workflow-visual-proof.json
|
||||
```
|
||||
|
||||
The snapshot includes session activity, tmux pane metadata, worker states, objectives, seeded overlays, and recent handoff summaries in JSON form.
|
||||
|
||||
## Operator Command-Center Handoff
|
||||
|
||||
When the workflow spans multiple sessions, worktrees, or tmux panes, append a control-plane block to the final handoff:
|
||||
|
||||
```markdown
|
||||
CONTROL PLANE
|
||||
-------------
|
||||
Sessions:
|
||||
- active session ID or alias
|
||||
- branch + worktree path for each active worker
|
||||
- tmux pane or detached session name when applicable
|
||||
|
||||
Diffs:
|
||||
- git status summary
|
||||
- git diff --stat for touched files
|
||||
- merge/conflict risk notes
|
||||
|
||||
Approvals:
|
||||
- pending user approvals
|
||||
- blocked steps awaiting confirmation
|
||||
|
||||
Telemetry:
|
||||
- last activity timestamp or idle signal
|
||||
- estimated token or cost drift
|
||||
- policy events raised by hooks or reviewers
|
||||
```
|
||||
|
||||
This keeps planner, implementer, reviewer, and loop workers legible from the operator surface.
|
||||
|
||||
## Arguments
|
||||
|
||||
$ARGUMENTS:
|
||||
|
||||
@@ -12,8 +12,6 @@ Manage Claude Code session history - list, load, alias, and edit sessions stored
|
||||
|
||||
Display all sessions with metadata, filtering, and pagination.
|
||||
|
||||
Use `/sessions info` when you need operator-surface context for a swarm: branch, worktree path, and session recency.
|
||||
|
||||
```bash
|
||||
/sessions # List all sessions (default)
|
||||
/sessions list # Same as above
|
||||
@@ -27,7 +25,6 @@ Use `/sessions info` when you need operator-surface context for a swarm: branch,
|
||||
node -e "
|
||||
const sm = require((process.env.CLAUDE_PLUGIN_ROOT||require('path').join(require('os').homedir(),'.claude'))+'/scripts/lib/session-manager');
|
||||
const aa = require((process.env.CLAUDE_PLUGIN_ROOT||require('path').join(require('os').homedir(),'.claude'))+'/scripts/lib/session-aliases');
|
||||
const path = require('path');
|
||||
|
||||
const result = sm.getAllSessions({ limit: 20 });
|
||||
const aliases = aa.listAliases();
|
||||
@@ -36,18 +33,17 @@ for (const a of aliases) aliasMap[a.sessionPath] = a.name;
|
||||
|
||||
console.log('Sessions (showing ' + result.sessions.length + ' of ' + result.total + '):');
|
||||
console.log('');
|
||||
console.log('ID Date Time Branch Worktree Alias');
|
||||
console.log('────────────────────────────────────────────────────────────────────');
|
||||
console.log('ID Date Time Size Lines Alias');
|
||||
console.log('────────────────────────────────────────────────────');
|
||||
|
||||
for (const s of result.sessions) {
|
||||
const alias = aliasMap[s.filename] || '';
|
||||
const metadata = sm.parseSessionMetadata(sm.getSessionContent(s.sessionPath));
|
||||
const size = sm.getSessionSize(s.sessionPath);
|
||||
const stats = sm.getSessionStats(s.sessionPath);
|
||||
const id = s.shortId === 'no-id' ? '(none)' : s.shortId.slice(0, 8);
|
||||
const time = s.modifiedTime.toTimeString().slice(0, 5);
|
||||
const branch = (metadata.branch || '-').slice(0, 12);
|
||||
const worktree = metadata.worktree ? path.basename(metadata.worktree).slice(0, 18) : '-';
|
||||
|
||||
console.log(id.padEnd(8) + ' ' + s.date + ' ' + time + ' ' + branch.padEnd(12) + ' ' + worktree.padEnd(18) + ' ' + alias);
|
||||
console.log(id.padEnd(8) + ' ' + s.date + ' ' + time + ' ' + size.padEnd(7) + ' ' + String(stats.lineCount).padEnd(5) + ' ' + alias);
|
||||
}
|
||||
"
|
||||
```
|
||||
@@ -112,18 +108,6 @@ if (session.metadata.started) {
|
||||
if (session.metadata.lastUpdated) {
|
||||
console.log('Last Updated: ' + session.metadata.lastUpdated);
|
||||
}
|
||||
|
||||
if (session.metadata.project) {
|
||||
console.log('Project: ' + session.metadata.project);
|
||||
}
|
||||
|
||||
if (session.metadata.branch) {
|
||||
console.log('Branch: ' + session.metadata.branch);
|
||||
}
|
||||
|
||||
if (session.metadata.worktree) {
|
||||
console.log('Worktree: ' + session.metadata.worktree);
|
||||
}
|
||||
" "$ARGUMENTS"
|
||||
```
|
||||
|
||||
@@ -231,9 +215,6 @@ console.log('ID: ' + (session.shortId === 'no-id' ? '(none)' : session.
|
||||
console.log('Filename: ' + session.filename);
|
||||
console.log('Date: ' + session.date);
|
||||
console.log('Modified: ' + session.modifiedTime.toISOString().slice(0, 19).replace('T', ' '));
|
||||
console.log('Project: ' + (session.metadata.project || '-'));
|
||||
console.log('Branch: ' + (session.metadata.branch || '-'));
|
||||
console.log('Worktree: ' + (session.metadata.worktree || '-'));
|
||||
console.log('');
|
||||
console.log('Content:');
|
||||
console.log(' Lines: ' + stats.lineCount);
|
||||
@@ -255,11 +236,6 @@ Show all session aliases.
|
||||
/sessions aliases # List all aliases
|
||||
```
|
||||
|
||||
## Operator Notes
|
||||
|
||||
- Session files persist `Project`, `Branch`, and `Worktree` in the header so `/sessions info` can disambiguate parallel tmux/worktree runs.
|
||||
- For command-center style monitoring, combine `/sessions info`, `git diff --stat`, and the cost metrics emitted by `scripts/hooks/cost-tracker.js`.
|
||||
|
||||
**Script:**
|
||||
```bash
|
||||
node -e "
|
||||
|
||||
@@ -72,11 +72,11 @@
|
||||
"env": {
|
||||
"EXA_API_KEY": "YOUR_EXA_API_KEY_HERE"
|
||||
},
|
||||
"description": "Web search, research, and data ingestion via Exa API — prefer task-scoped use for broader research after GitHub search and primary docs"
|
||||
"description": "Web search, research, and data ingestion via Exa API — recommended for research-first development workflow"
|
||||
},
|
||||
"context7": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@upstash/context7-mcp@latest"],
|
||||
"args": ["-y", "@context7/mcp-server"],
|
||||
"description": "Live documentation lookup"
|
||||
},
|
||||
"magic": {
|
||||
@@ -93,50 +93,6 @@
|
||||
"command": "python3",
|
||||
"args": ["-m", "insa_its.mcp_server"],
|
||||
"description": "AI-to-AI security monitoring — anomaly detection, credential exposure, hallucination checks, forensic tracing. 23 anomaly types, OWASP MCP Top 10 coverage. 100% local. Install: pip install insa-its"
|
||||
},
|
||||
"playwright": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@playwright/mcp", "--browser", "chrome"],
|
||||
"description": "Browser automation and testing via Playwright"
|
||||
},
|
||||
"fal-ai": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "fal-ai-mcp-server"],
|
||||
"env": {
|
||||
"FAL_KEY": "YOUR_FAL_KEY_HERE"
|
||||
},
|
||||
"description": "AI image/video/audio generation via fal.ai models"
|
||||
},
|
||||
"browserbase": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@browserbasehq/mcp-server-browserbase"],
|
||||
"env": {
|
||||
"BROWSERBASE_API_KEY": "YOUR_BROWSERBASE_KEY_HERE"
|
||||
},
|
||||
"description": "Cloud browser sessions via Browserbase"
|
||||
},
|
||||
"browser-use": {
|
||||
"type": "http",
|
||||
"url": "https://api.browser-use.com/mcp",
|
||||
"headers": {
|
||||
"x-browser-use-api-key": "YOUR_BROWSER_USE_KEY_HERE"
|
||||
},
|
||||
"description": "AI browser agent for web tasks"
|
||||
},
|
||||
"token-optimizer": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "token-optimizer-mcp"],
|
||||
"description": "Token optimization for 95%+ context reduction via content deduplication and compression"
|
||||
},
|
||||
"confluence": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "confluence-mcp-server"],
|
||||
"env": {
|
||||
"CONFLUENCE_BASE_URL": "YOUR_CONFLUENCE_URL_HERE",
|
||||
"CONFLUENCE_EMAIL": "YOUR_EMAIL_HERE",
|
||||
"CONFLUENCE_API_TOKEN": "YOUR_CONFLUENCE_TOKEN_HERE"
|
||||
},
|
||||
"description": "Confluence Cloud integration — search pages, retrieve content, explore spaces"
|
||||
}
|
||||
},
|
||||
"_comments": {
|
||||
|
||||
@@ -67,9 +67,6 @@
|
||||
"scripts/hooks/",
|
||||
"scripts/lib/",
|
||||
"scripts/claw.js",
|
||||
"scripts/orchestration-status.js",
|
||||
"scripts/orchestrate-codex-worker.sh",
|
||||
"scripts/orchestrate-worktrees.js",
|
||||
"scripts/setup-package-manager.js",
|
||||
"scripts/skill-create-output.js",
|
||||
"skills/",
|
||||
@@ -86,9 +83,6 @@
|
||||
"postinstall": "echo '\\n ecc-universal installed!\\n Run: npx ecc-install typescript\\n Docs: https://github.com/affaan-m/everything-claude-code\\n'",
|
||||
"lint": "eslint . && markdownlint '**/*.md' --ignore node_modules",
|
||||
"claw": "node scripts/claw.js",
|
||||
"orchestrate:status": "node scripts/orchestration-status.js",
|
||||
"orchestrate:worker": "bash scripts/orchestrate-codex-worker.sh",
|
||||
"orchestrate:tmux": "node scripts/orchestrate-worktrees.js",
|
||||
"test": "node scripts/ci/validate-agents.js && node scripts/ci/validate-commands.js && node scripts/ci/validate-rules.js && node scripts/ci/validate-skills.js && node scripts/ci/validate-hooks.js && node scripts/ci/validate-no-personal-paths.js && node tests/run-all.js",
|
||||
"coverage": "c8 --all --include=\"scripts/**/*.js\" --check-coverage --lines 80 --functions 80 --branches 80 --statements 80 --reporter=text --reporter=lcov node tests/run-all.js"
|
||||
},
|
||||
|
||||
@@ -8,8 +8,7 @@ The Feature Implementation Workflow describes the development pipeline: research
|
||||
|
||||
0. **Research & Reuse** _(mandatory before any new implementation)_
|
||||
- **GitHub code search first:** Run `gh search repos` and `gh search code` to find existing implementations, templates, and patterns before writing anything new.
|
||||
- **Library docs second:** Use Context7 or primary vendor docs to confirm API behavior, package usage, and version-specific details before implementing.
|
||||
- **Exa only when the first two are insufficient:** Use Exa for broader web research or discovery after GitHub search and primary docs.
|
||||
- **Exa MCP for research:** Use `exa-web-search` MCP during the planning phase for broader research, data ingestion, and discovering prior art.
|
||||
- **Check package registries:** Search npm, PyPI, crates.io, and other registries before writing utility code. Prefer battle-tested libraries over hand-rolled solutions.
|
||||
- **Search for adaptable implementations:** Look for open-source projects that solve 80%+ of the problem and can be forked, ported, or wrapped.
|
||||
- Prefer adopting or porting a proven approach over writing net-new code when it meets the requirement.
|
||||
|
||||
@@ -16,17 +16,15 @@ const {
|
||||
getDateString,
|
||||
getTimeString,
|
||||
getSessionIdShort,
|
||||
getProjectName,
|
||||
ensureDir,
|
||||
readFile,
|
||||
writeFile,
|
||||
runCommand,
|
||||
replaceInFile,
|
||||
log
|
||||
} = require('../lib/utils');
|
||||
|
||||
const SUMMARY_START_MARKER = '<!-- ECC:SUMMARY:START -->';
|
||||
const SUMMARY_END_MARKER = '<!-- ECC:SUMMARY:END -->';
|
||||
const SESSION_SEPARATOR = '\n---\n';
|
||||
|
||||
/**
|
||||
* Extract a meaningful summary from the session transcript.
|
||||
@@ -130,51 +128,6 @@ function runMain() {
|
||||
});
|
||||
}
|
||||
|
||||
function getSessionMetadata() {
|
||||
const branchResult = runCommand('git rev-parse --abbrev-ref HEAD');
|
||||
|
||||
return {
|
||||
project: getProjectName() || 'unknown',
|
||||
branch: branchResult.success ? branchResult.output : 'unknown',
|
||||
worktree: process.cwd()
|
||||
};
|
||||
}
|
||||
|
||||
function extractHeaderField(header, label) {
|
||||
const match = header.match(new RegExp(`\\*\\*${escapeRegExp(label)}:\\*\\*\\s*(.+)$`, 'm'));
|
||||
return match ? match[1].trim() : null;
|
||||
}
|
||||
|
||||
function buildSessionHeader(today, currentTime, metadata, existingContent = '') {
|
||||
const headingMatch = existingContent.match(/^#\s+.+$/m);
|
||||
const heading = headingMatch ? headingMatch[0] : `# Session: ${today}`;
|
||||
const date = extractHeaderField(existingContent, 'Date') || today;
|
||||
const started = extractHeaderField(existingContent, 'Started') || currentTime;
|
||||
|
||||
return [
|
||||
heading,
|
||||
`**Date:** ${date}`,
|
||||
`**Started:** ${started}`,
|
||||
`**Last Updated:** ${currentTime}`,
|
||||
`**Project:** ${metadata.project}`,
|
||||
`**Branch:** ${metadata.branch}`,
|
||||
`**Worktree:** ${metadata.worktree}`,
|
||||
''
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function mergeSessionHeader(content, today, currentTime, metadata) {
|
||||
const separatorIndex = content.indexOf(SESSION_SEPARATOR);
|
||||
if (separatorIndex === -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const existingHeader = content.slice(0, separatorIndex);
|
||||
const body = content.slice(separatorIndex + SESSION_SEPARATOR.length);
|
||||
const nextHeader = buildSessionHeader(today, currentTime, metadata, existingHeader);
|
||||
return `${nextHeader}${SESSION_SEPARATOR}${body}`;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Parse stdin JSON to get transcript_path
|
||||
let transcriptPath = null;
|
||||
@@ -190,7 +143,6 @@ async function main() {
|
||||
const today = getDateString();
|
||||
const shortId = getSessionIdShort();
|
||||
const sessionFile = path.join(sessionsDir, `${today}-${shortId}-session.tmp`);
|
||||
const sessionMetadata = getSessionMetadata();
|
||||
|
||||
ensureDir(sessionsDir);
|
||||
|
||||
@@ -208,42 +160,42 @@ async function main() {
|
||||
}
|
||||
|
||||
if (fs.existsSync(sessionFile)) {
|
||||
const existing = readFile(sessionFile);
|
||||
let updatedContent = existing;
|
||||
|
||||
if (existing) {
|
||||
const merged = mergeSessionHeader(existing, today, currentTime, sessionMetadata);
|
||||
if (merged) {
|
||||
updatedContent = merged;
|
||||
} else {
|
||||
log(`[SessionEnd] Failed to normalize header in ${sessionFile}`);
|
||||
}
|
||||
// Update existing session file
|
||||
const updated = replaceInFile(
|
||||
sessionFile,
|
||||
/\*\*Last Updated:\*\*.*/,
|
||||
`**Last Updated:** ${currentTime}`
|
||||
);
|
||||
if (!updated) {
|
||||
log(`[SessionEnd] Failed to update timestamp in ${sessionFile}`);
|
||||
}
|
||||
|
||||
// If we have a new summary, update only the generated summary block.
|
||||
// This keeps repeated Stop invocations idempotent and preserves
|
||||
// user-authored sections in the same session file.
|
||||
if (summary && updatedContent) {
|
||||
const summaryBlock = buildSummaryBlock(summary);
|
||||
if (summary) {
|
||||
const existing = readFile(sessionFile);
|
||||
if (existing) {
|
||||
const summaryBlock = buildSummaryBlock(summary);
|
||||
let updatedContent = existing;
|
||||
|
||||
if (updatedContent.includes(SUMMARY_START_MARKER) && updatedContent.includes(SUMMARY_END_MARKER)) {
|
||||
updatedContent = updatedContent.replace(
|
||||
new RegExp(`${escapeRegExp(SUMMARY_START_MARKER)}[\\s\\S]*?${escapeRegExp(SUMMARY_END_MARKER)}`),
|
||||
summaryBlock
|
||||
);
|
||||
} else {
|
||||
// Migration path for files created before summary markers existed.
|
||||
updatedContent = updatedContent.replace(
|
||||
/## (?:Session Summary|Current State)[\s\S]*?$/,
|
||||
`${summaryBlock}\n\n### Notes for Next Session\n-\n\n### Context to Load\n\`\`\`\n[relevant files]\n\`\`\`\n`
|
||||
);
|
||||
if (existing.includes(SUMMARY_START_MARKER) && existing.includes(SUMMARY_END_MARKER)) {
|
||||
updatedContent = existing.replace(
|
||||
new RegExp(`${escapeRegExp(SUMMARY_START_MARKER)}[\\s\\S]*?${escapeRegExp(SUMMARY_END_MARKER)}`),
|
||||
summaryBlock
|
||||
);
|
||||
} else {
|
||||
// Migration path for files created before summary markers existed.
|
||||
updatedContent = existing.replace(
|
||||
/## (?:Session Summary|Current State)[\s\S]*?$/,
|
||||
`${summaryBlock}\n\n### Notes for Next Session\n-\n\n### Context to Load\n\`\`\`\n[relevant files]\n\`\`\`\n`
|
||||
);
|
||||
}
|
||||
|
||||
writeFile(sessionFile, updatedContent);
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedContent) {
|
||||
writeFile(sessionFile, updatedContent);
|
||||
}
|
||||
|
||||
log(`[SessionEnd] Updated session file: ${sessionFile}`);
|
||||
} else {
|
||||
// Create new session file
|
||||
@@ -251,7 +203,14 @@ async function main() {
|
||||
? `${buildSummaryBlock(summary)}\n\n### Notes for Next Session\n-\n\n### Context to Load\n\`\`\`\n[relevant files]\n\`\`\``
|
||||
: `## Current State\n\n[Session context goes here]\n\n### Completed\n- [ ]\n\n### In Progress\n- [ ]\n\n### Notes for Next Session\n-\n\n### Context to Load\n\`\`\`\n[relevant files]\n\`\`\``;
|
||||
|
||||
const template = `${buildSessionHeader(today, currentTime, sessionMetadata)}${SESSION_SEPARATOR}${summarySection}
|
||||
const template = `# Session: ${today}
|
||||
**Date:** ${today}
|
||||
**Started:** ${currentTime}
|
||||
**Last Updated:** ${currentTime}
|
||||
|
||||
---
|
||||
|
||||
${summarySection}
|
||||
`;
|
||||
|
||||
writeFile(sessionFile, template);
|
||||
|
||||
@@ -1,295 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
function stripCodeTicks(value) {
|
||||
if (typeof value !== 'string') {
|
||||
return value;
|
||||
}
|
||||
|
||||
const trimmed = value.trim();
|
||||
if (trimmed.startsWith('`') && trimmed.endsWith('`') && trimmed.length >= 2) {
|
||||
return trimmed.slice(1, -1);
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
function parseSection(content, heading) {
|
||||
if (typeof content !== 'string' || content.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const lines = content.split('\n');
|
||||
const headingLines = new Set([`## ${heading}`, `**${heading}**`]);
|
||||
const startIndex = lines.findIndex(line => headingLines.has(line.trim()));
|
||||
|
||||
if (startIndex === -1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const collected = [];
|
||||
for (let index = startIndex + 1; index < lines.length; index += 1) {
|
||||
const line = lines[index];
|
||||
const trimmed = line.trim();
|
||||
if (trimmed.startsWith('## ') || (/^\*\*.+\*\*$/.test(trimmed) && !headingLines.has(trimmed))) {
|
||||
break;
|
||||
}
|
||||
collected.push(line);
|
||||
}
|
||||
|
||||
return collected.join('\n').trim();
|
||||
}
|
||||
|
||||
function parseBullets(section) {
|
||||
if (!section) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return section
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter(line => line.startsWith('- '))
|
||||
.map(line => stripCodeTicks(line.replace(/^- /, '').trim()));
|
||||
}
|
||||
|
||||
function parseWorkerStatus(content) {
|
||||
const status = {
|
||||
state: null,
|
||||
updated: null,
|
||||
branch: null,
|
||||
worktree: null,
|
||||
taskFile: null,
|
||||
handoffFile: null
|
||||
};
|
||||
|
||||
if (typeof content !== 'string' || content.length === 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
for (const line of content.split('\n')) {
|
||||
const match = line.match(/^- ([A-Za-z ]+):\s*(.+)$/);
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const key = match[1].trim().toLowerCase().replace(/\s+/g, '');
|
||||
const value = stripCodeTicks(match[2]);
|
||||
|
||||
if (key === 'state') status.state = value;
|
||||
if (key === 'updated') status.updated = value;
|
||||
if (key === 'branch') status.branch = value;
|
||||
if (key === 'worktree') status.worktree = value;
|
||||
if (key === 'taskfile') status.taskFile = value;
|
||||
if (key === 'handofffile') status.handoffFile = value;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
function parseWorkerTask(content) {
|
||||
return {
|
||||
objective: parseSection(content, 'Objective'),
|
||||
seedPaths: parseBullets(parseSection(content, 'Seeded Local Overlays'))
|
||||
};
|
||||
}
|
||||
|
||||
function parseWorkerHandoff(content) {
|
||||
return {
|
||||
summary: parseBullets(parseSection(content, 'Summary')),
|
||||
validation: parseBullets(parseSection(content, 'Validation')),
|
||||
remainingRisks: parseBullets(parseSection(content, 'Remaining Risks'))
|
||||
};
|
||||
}
|
||||
|
||||
function readTextIfExists(filePath) {
|
||||
if (!filePath || !fs.existsSync(filePath)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return fs.readFileSync(filePath, 'utf8');
|
||||
}
|
||||
|
||||
function listWorkerDirectories(coordinationDir) {
|
||||
if (!coordinationDir || !fs.existsSync(coordinationDir)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return fs.readdirSync(coordinationDir, { withFileTypes: true })
|
||||
.filter(entry => entry.isDirectory())
|
||||
.filter(entry => {
|
||||
const workerDir = path.join(coordinationDir, entry.name);
|
||||
return ['status.md', 'task.md', 'handoff.md']
|
||||
.some(filename => fs.existsSync(path.join(workerDir, filename)));
|
||||
})
|
||||
.map(entry => entry.name)
|
||||
.sort();
|
||||
}
|
||||
|
||||
function loadWorkerSnapshots(coordinationDir) {
|
||||
return listWorkerDirectories(coordinationDir).map(workerSlug => {
|
||||
const workerDir = path.join(coordinationDir, workerSlug);
|
||||
const statusPath = path.join(workerDir, 'status.md');
|
||||
const taskPath = path.join(workerDir, 'task.md');
|
||||
const handoffPath = path.join(workerDir, 'handoff.md');
|
||||
|
||||
const status = parseWorkerStatus(readTextIfExists(statusPath));
|
||||
const task = parseWorkerTask(readTextIfExists(taskPath));
|
||||
const handoff = parseWorkerHandoff(readTextIfExists(handoffPath));
|
||||
|
||||
return {
|
||||
workerSlug,
|
||||
workerDir,
|
||||
status,
|
||||
task,
|
||||
handoff,
|
||||
files: {
|
||||
status: statusPath,
|
||||
task: taskPath,
|
||||
handoff: handoffPath
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function listTmuxPanes(sessionName) {
|
||||
const format = [
|
||||
'#{pane_id}',
|
||||
'#{window_index}',
|
||||
'#{pane_index}',
|
||||
'#{pane_title}',
|
||||
'#{pane_current_command}',
|
||||
'#{pane_current_path}',
|
||||
'#{pane_active}',
|
||||
'#{pane_dead}',
|
||||
'#{pane_pid}'
|
||||
].join('\t');
|
||||
|
||||
const result = spawnSync('tmux', ['list-panes', '-t', sessionName, '-F', format], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
if (result.status !== 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return (result.stdout || '')
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter(Boolean)
|
||||
.map(line => {
|
||||
const [
|
||||
paneId,
|
||||
windowIndex,
|
||||
paneIndex,
|
||||
title,
|
||||
currentCommand,
|
||||
currentPath,
|
||||
active,
|
||||
dead,
|
||||
pid
|
||||
] = line.split('\t');
|
||||
|
||||
return {
|
||||
paneId,
|
||||
windowIndex: Number(windowIndex),
|
||||
paneIndex: Number(paneIndex),
|
||||
title,
|
||||
currentCommand,
|
||||
currentPath,
|
||||
active: active === '1',
|
||||
dead: dead === '1',
|
||||
pid: pid ? Number(pid) : null
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function summarizeWorkerStates(workers) {
|
||||
return workers.reduce((counts, worker) => {
|
||||
const state = worker.status.state || 'unknown';
|
||||
counts[state] = (counts[state] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function buildSessionSnapshot({ sessionName, coordinationDir, panes }) {
|
||||
const workerSnapshots = loadWorkerSnapshots(coordinationDir);
|
||||
const paneMap = new Map(panes.map(pane => [pane.title, pane]));
|
||||
|
||||
const workers = workerSnapshots.map(worker => ({
|
||||
...worker,
|
||||
pane: paneMap.get(worker.workerSlug) || null
|
||||
}));
|
||||
|
||||
return {
|
||||
sessionName,
|
||||
coordinationDir,
|
||||
sessionActive: panes.length > 0,
|
||||
paneCount: panes.length,
|
||||
workerCount: workers.length,
|
||||
workerStates: summarizeWorkerStates(workers),
|
||||
panes,
|
||||
workers
|
||||
};
|
||||
}
|
||||
|
||||
function resolveSnapshotTarget(targetPath, cwd = process.cwd()) {
|
||||
const absoluteTarget = path.resolve(cwd, targetPath);
|
||||
|
||||
if (fs.existsSync(absoluteTarget) && fs.statSync(absoluteTarget).isFile()) {
|
||||
const config = JSON.parse(fs.readFileSync(absoluteTarget, 'utf8'));
|
||||
const repoRoot = path.resolve(config.repoRoot || cwd);
|
||||
const coordinationRoot = path.resolve(
|
||||
config.coordinationRoot || path.join(repoRoot, '.orchestration')
|
||||
);
|
||||
|
||||
return {
|
||||
sessionName: config.sessionName,
|
||||
coordinationDir: path.join(coordinationRoot, config.sessionName),
|
||||
repoRoot,
|
||||
targetType: 'plan'
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
sessionName: targetPath,
|
||||
coordinationDir: path.join(cwd, '.claude', 'orchestration', targetPath),
|
||||
repoRoot: cwd,
|
||||
targetType: 'session'
|
||||
};
|
||||
}
|
||||
|
||||
function collectSessionSnapshot(targetPath, cwd = process.cwd()) {
|
||||
const target = resolveSnapshotTarget(targetPath, cwd);
|
||||
const panes = listTmuxPanes(target.sessionName);
|
||||
const snapshot = buildSessionSnapshot({
|
||||
sessionName: target.sessionName,
|
||||
coordinationDir: target.coordinationDir,
|
||||
panes
|
||||
});
|
||||
|
||||
return {
|
||||
...snapshot,
|
||||
repoRoot: target.repoRoot,
|
||||
targetType: target.targetType
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buildSessionSnapshot,
|
||||
collectSessionSnapshot,
|
||||
listTmuxPanes,
|
||||
loadWorkerSnapshots,
|
||||
normalizeText: stripCodeTicks,
|
||||
parseWorkerHandoff,
|
||||
parseWorkerStatus,
|
||||
parseWorkerTask,
|
||||
resolveSnapshotTarget
|
||||
};
|
||||
@@ -85,9 +85,6 @@ function parseSessionMetadata(content) {
|
||||
date: null,
|
||||
started: null,
|
||||
lastUpdated: null,
|
||||
project: null,
|
||||
branch: null,
|
||||
worktree: null,
|
||||
completed: [],
|
||||
inProgress: [],
|
||||
notes: '',
|
||||
@@ -120,22 +117,6 @@ function parseSessionMetadata(content) {
|
||||
metadata.lastUpdated = updatedMatch[1];
|
||||
}
|
||||
|
||||
// Extract control-plane metadata
|
||||
const projectMatch = content.match(/\*\*Project:\*\*\s*(.+)$/m);
|
||||
if (projectMatch) {
|
||||
metadata.project = projectMatch[1].trim();
|
||||
}
|
||||
|
||||
const branchMatch = content.match(/\*\*Branch:\*\*\s*(.+)$/m);
|
||||
if (branchMatch) {
|
||||
metadata.branch = branchMatch[1].trim();
|
||||
}
|
||||
|
||||
const worktreeMatch = content.match(/\*\*Worktree:\*\*\s*(.+)$/m);
|
||||
if (worktreeMatch) {
|
||||
metadata.worktree = worktreeMatch[1].trim();
|
||||
}
|
||||
|
||||
// Extract completed items
|
||||
const completedSection = content.match(/### Completed\s*\n([\s\S]*?)(?=###|\n\n|$)/);
|
||||
if (completedSection) {
|
||||
|
||||
@@ -1,491 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
function slugify(value, fallback = 'worker') {
|
||||
const normalized = String(value || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '');
|
||||
return normalized || fallback;
|
||||
}
|
||||
|
||||
function renderTemplate(template, variables) {
|
||||
if (typeof template !== 'string' || template.trim().length === 0) {
|
||||
throw new Error('launcherCommand must be a non-empty string');
|
||||
}
|
||||
|
||||
return template.replace(/\{([a-z_]+)\}/g, (match, key) => {
|
||||
if (!(key in variables)) {
|
||||
throw new Error(`Unknown template variable: ${key}`);
|
||||
}
|
||||
return String(variables[key]);
|
||||
});
|
||||
}
|
||||
|
||||
function shellQuote(value) {
|
||||
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
||||
}
|
||||
|
||||
function formatCommand(program, args) {
|
||||
return [program, ...args.map(shellQuote)].join(' ');
|
||||
}
|
||||
|
||||
function normalizeSeedPaths(seedPaths, repoRoot) {
|
||||
const resolvedRepoRoot = path.resolve(repoRoot);
|
||||
const entries = Array.isArray(seedPaths) ? seedPaths : [];
|
||||
const seen = new Set();
|
||||
const normalized = [];
|
||||
|
||||
for (const entry of entries) {
|
||||
if (typeof entry !== 'string' || entry.trim().length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const absolutePath = path.resolve(resolvedRepoRoot, entry);
|
||||
const relativePath = path.relative(resolvedRepoRoot, absolutePath);
|
||||
|
||||
if (
|
||||
relativePath.startsWith('..') ||
|
||||
path.isAbsolute(relativePath)
|
||||
) {
|
||||
throw new Error(`seedPaths entries must stay inside repoRoot: ${entry}`);
|
||||
}
|
||||
|
||||
const normalizedPath = relativePath.split(path.sep).join('/');
|
||||
if (seen.has(normalizedPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
seen.add(normalizedPath);
|
||||
normalized.push(normalizedPath);
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function overlaySeedPaths({ repoRoot, seedPaths, worktreePath }) {
|
||||
const normalizedSeedPaths = normalizeSeedPaths(seedPaths, repoRoot);
|
||||
|
||||
for (const seedPath of normalizedSeedPaths) {
|
||||
const sourcePath = path.join(repoRoot, seedPath);
|
||||
const destinationPath = path.join(worktreePath, seedPath);
|
||||
|
||||
if (!fs.existsSync(sourcePath)) {
|
||||
throw new Error(`Seed path does not exist in repoRoot: ${seedPath}`);
|
||||
}
|
||||
|
||||
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
|
||||
fs.rmSync(destinationPath, { force: true, recursive: true });
|
||||
fs.cpSync(sourcePath, destinationPath, {
|
||||
dereference: false,
|
||||
force: true,
|
||||
preserveTimestamps: true,
|
||||
recursive: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function buildWorkerArtifacts(workerPlan) {
|
||||
const seededPathsSection = workerPlan.seedPaths.length > 0
|
||||
? [
|
||||
'',
|
||||
'## Seeded Local Overlays',
|
||||
...workerPlan.seedPaths.map(seedPath => `- \`${seedPath}\``)
|
||||
]
|
||||
: [];
|
||||
|
||||
return {
|
||||
dir: workerPlan.coordinationDir,
|
||||
files: [
|
||||
{
|
||||
path: workerPlan.taskFilePath,
|
||||
content: [
|
||||
`# Worker Task: ${workerPlan.workerName}`,
|
||||
'',
|
||||
`- Session: \`${workerPlan.sessionName}\``,
|
||||
`- Repo root: \`${workerPlan.repoRoot}\``,
|
||||
`- Worktree: \`${workerPlan.worktreePath}\``,
|
||||
`- Branch: \`${workerPlan.branchName}\``,
|
||||
`- Launcher status file: \`${workerPlan.statusFilePath}\``,
|
||||
`- Launcher handoff file: \`${workerPlan.handoffFilePath}\``,
|
||||
...seededPathsSection,
|
||||
'',
|
||||
'## Objective',
|
||||
workerPlan.task,
|
||||
'',
|
||||
'## Completion',
|
||||
'Do not spawn subagents or external agents for this task.',
|
||||
'Report results in your final response.',
|
||||
`The worker launcher captures your response in \`${workerPlan.handoffFilePath}\` automatically.`,
|
||||
`The worker launcher updates \`${workerPlan.statusFilePath}\` automatically.`
|
||||
].join('\n')
|
||||
},
|
||||
{
|
||||
path: workerPlan.handoffFilePath,
|
||||
content: [
|
||||
`# Handoff: ${workerPlan.workerName}`,
|
||||
'',
|
||||
'## Summary',
|
||||
'- Pending',
|
||||
'',
|
||||
'## Files Changed',
|
||||
'- Pending',
|
||||
'',
|
||||
'## Tests / Verification',
|
||||
'- Pending',
|
||||
'',
|
||||
'## Follow-ups',
|
||||
'- Pending'
|
||||
].join('\n')
|
||||
},
|
||||
{
|
||||
path: workerPlan.statusFilePath,
|
||||
content: [
|
||||
`# Status: ${workerPlan.workerName}`,
|
||||
'',
|
||||
'- State: not started',
|
||||
`- Worktree: \`${workerPlan.worktreePath}\``,
|
||||
`- Branch: \`${workerPlan.branchName}\``
|
||||
].join('\n')
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function buildOrchestrationPlan(config = {}) {
|
||||
const repoRoot = path.resolve(config.repoRoot || process.cwd());
|
||||
const repoName = path.basename(repoRoot);
|
||||
const workers = Array.isArray(config.workers) ? config.workers : [];
|
||||
const globalSeedPaths = normalizeSeedPaths(config.seedPaths, repoRoot);
|
||||
const sessionName = slugify(config.sessionName || repoName, 'session');
|
||||
const worktreeRoot = path.resolve(config.worktreeRoot || path.dirname(repoRoot));
|
||||
const coordinationRoot = path.resolve(
|
||||
config.coordinationRoot || path.join(repoRoot, '.orchestration')
|
||||
);
|
||||
const coordinationDir = path.join(coordinationRoot, sessionName);
|
||||
const baseRef = config.baseRef || 'HEAD';
|
||||
const defaultLauncher = config.launcherCommand || '';
|
||||
|
||||
if (workers.length === 0) {
|
||||
throw new Error('buildOrchestrationPlan requires at least one worker');
|
||||
}
|
||||
|
||||
const workerPlans = workers.map((worker, index) => {
|
||||
if (!worker || typeof worker.task !== 'string' || worker.task.trim().length === 0) {
|
||||
throw new Error(`Worker ${index + 1} is missing a task`);
|
||||
}
|
||||
|
||||
const workerName = worker.name || `worker-${index + 1}`;
|
||||
const workerSlug = slugify(workerName, `worker-${index + 1}`);
|
||||
const branchName = `orchestrator-${sessionName}-${workerSlug}`;
|
||||
const worktreePath = path.join(worktreeRoot, `${repoName}-${sessionName}-${workerSlug}`);
|
||||
const workerCoordinationDir = path.join(coordinationDir, workerSlug);
|
||||
const taskFilePath = path.join(workerCoordinationDir, 'task.md');
|
||||
const handoffFilePath = path.join(workerCoordinationDir, 'handoff.md');
|
||||
const statusFilePath = path.join(workerCoordinationDir, 'status.md');
|
||||
const launcherCommand = worker.launcherCommand || defaultLauncher;
|
||||
const workerSeedPaths = normalizeSeedPaths(worker.seedPaths, repoRoot);
|
||||
const seedPaths = normalizeSeedPaths([...globalSeedPaths, ...workerSeedPaths], repoRoot);
|
||||
const templateVariables = {
|
||||
branch_name: branchName,
|
||||
handoff_file: handoffFilePath,
|
||||
repo_root: repoRoot,
|
||||
session_name: sessionName,
|
||||
status_file: statusFilePath,
|
||||
task_file: taskFilePath,
|
||||
worker_name: workerName,
|
||||
worker_slug: workerSlug,
|
||||
worktree_path: worktreePath
|
||||
};
|
||||
|
||||
if (!launcherCommand) {
|
||||
throw new Error(`Worker ${workerName} is missing a launcherCommand`);
|
||||
}
|
||||
|
||||
const gitArgs = ['worktree', 'add', '-b', branchName, worktreePath, baseRef];
|
||||
|
||||
return {
|
||||
branchName,
|
||||
coordinationDir: workerCoordinationDir,
|
||||
gitArgs,
|
||||
gitCommand: formatCommand('git', gitArgs),
|
||||
handoffFilePath,
|
||||
launchCommand: renderTemplate(launcherCommand, templateVariables),
|
||||
repoRoot,
|
||||
sessionName,
|
||||
seedPaths,
|
||||
statusFilePath,
|
||||
task: worker.task.trim(),
|
||||
taskFilePath,
|
||||
workerName,
|
||||
workerSlug,
|
||||
worktreePath
|
||||
};
|
||||
});
|
||||
|
||||
const tmuxCommands = [
|
||||
{
|
||||
cmd: 'tmux',
|
||||
args: ['new-session', '-d', '-s', sessionName, '-n', 'orchestrator', '-c', repoRoot],
|
||||
description: 'Create detached tmux session'
|
||||
},
|
||||
{
|
||||
cmd: 'tmux',
|
||||
args: [
|
||||
'send-keys',
|
||||
'-t',
|
||||
sessionName,
|
||||
`printf '%s\\n' 'Session: ${sessionName}' 'Coordination: ${coordinationDir}'`,
|
||||
'C-m'
|
||||
],
|
||||
description: 'Print orchestrator session details'
|
||||
}
|
||||
];
|
||||
|
||||
for (const workerPlan of workerPlans) {
|
||||
tmuxCommands.push(
|
||||
{
|
||||
cmd: 'tmux',
|
||||
args: ['split-window', '-d', '-t', sessionName, '-c', workerPlan.worktreePath],
|
||||
description: `Create pane for ${workerPlan.workerName}`
|
||||
},
|
||||
{
|
||||
cmd: 'tmux',
|
||||
args: ['select-layout', '-t', sessionName, 'tiled'],
|
||||
description: 'Arrange panes in tiled layout'
|
||||
},
|
||||
{
|
||||
cmd: 'tmux',
|
||||
args: ['select-pane', '-t', '<pane-id>', '-T', workerPlan.workerSlug],
|
||||
description: `Label pane ${workerPlan.workerSlug}`
|
||||
},
|
||||
{
|
||||
cmd: 'tmux',
|
||||
args: [
|
||||
'send-keys',
|
||||
'-t',
|
||||
'<pane-id>',
|
||||
`cd ${shellQuote(workerPlan.worktreePath)} && ${workerPlan.launchCommand}`,
|
||||
'C-m'
|
||||
],
|
||||
description: `Launch worker ${workerPlan.workerName}`
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
baseRef,
|
||||
coordinationDir,
|
||||
replaceExisting: Boolean(config.replaceExisting),
|
||||
repoRoot,
|
||||
sessionName,
|
||||
tmuxCommands,
|
||||
workerPlans
|
||||
};
|
||||
}
|
||||
|
||||
function materializePlan(plan) {
|
||||
for (const workerPlan of plan.workerPlans) {
|
||||
const artifacts = buildWorkerArtifacts(workerPlan);
|
||||
fs.mkdirSync(artifacts.dir, { recursive: true });
|
||||
for (const file of artifacts.files) {
|
||||
fs.writeFileSync(file.path, file.content + '\n', 'utf8');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function runCommand(program, args, options = {}) {
|
||||
const result = spawnSync(program, args, {
|
||||
cwd: options.cwd,
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
if (result.status !== 0) {
|
||||
const stderr = (result.stderr || '').trim();
|
||||
throw new Error(`${program} ${args.join(' ')} failed${stderr ? `: ${stderr}` : ''}`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function commandSucceeds(program, args, options = {}) {
|
||||
const result = spawnSync(program, args, {
|
||||
cwd: options.cwd,
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
});
|
||||
return result.status === 0;
|
||||
}
|
||||
|
||||
function canonicalizePath(targetPath) {
|
||||
const resolvedPath = path.resolve(targetPath);
|
||||
|
||||
try {
|
||||
return fs.realpathSync.native(resolvedPath);
|
||||
} catch (error) {
|
||||
const parentPath = path.dirname(resolvedPath);
|
||||
|
||||
try {
|
||||
return path.join(fs.realpathSync.native(parentPath), path.basename(resolvedPath));
|
||||
} catch (parentError) {
|
||||
return resolvedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function branchExists(repoRoot, branchName) {
|
||||
return commandSucceeds('git', ['show-ref', '--verify', '--quiet', `refs/heads/${branchName}`], {
|
||||
cwd: repoRoot
|
||||
});
|
||||
}
|
||||
|
||||
function listWorktrees(repoRoot) {
|
||||
const listed = runCommand('git', ['worktree', 'list', '--porcelain'], { cwd: repoRoot });
|
||||
const lines = (listed.stdout || '').split('\n');
|
||||
const worktrees = [];
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('worktree ')) {
|
||||
const listedPath = line.slice('worktree '.length).trim();
|
||||
worktrees.push({
|
||||
listedPath,
|
||||
canonicalPath: canonicalizePath(listedPath)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return worktrees;
|
||||
}
|
||||
|
||||
function cleanupExisting(plan) {
|
||||
runCommand('git', ['worktree', 'prune', '--expire', 'now'], { cwd: plan.repoRoot });
|
||||
|
||||
const hasSession = spawnSync('tmux', ['has-session', '-t', plan.sessionName], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
});
|
||||
|
||||
if (hasSession.status === 0) {
|
||||
runCommand('tmux', ['kill-session', '-t', plan.sessionName], { cwd: plan.repoRoot });
|
||||
}
|
||||
|
||||
for (const workerPlan of plan.workerPlans) {
|
||||
const expectedWorktreePath = canonicalizePath(workerPlan.worktreePath);
|
||||
const existingWorktree = listWorktrees(plan.repoRoot).find(
|
||||
worktree => worktree.canonicalPath === expectedWorktreePath
|
||||
);
|
||||
|
||||
if (existingWorktree) {
|
||||
runCommand('git', ['worktree', 'remove', '--force', existingWorktree.listedPath], {
|
||||
cwd: plan.repoRoot
|
||||
});
|
||||
}
|
||||
|
||||
if (fs.existsSync(workerPlan.worktreePath)) {
|
||||
fs.rmSync(workerPlan.worktreePath, { force: true, recursive: true });
|
||||
}
|
||||
|
||||
runCommand('git', ['worktree', 'prune', '--expire', 'now'], { cwd: plan.repoRoot });
|
||||
|
||||
if (branchExists(plan.repoRoot, workerPlan.branchName)) {
|
||||
runCommand('git', ['branch', '-D', workerPlan.branchName], { cwd: plan.repoRoot });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function executePlan(plan) {
|
||||
runCommand('git', ['rev-parse', '--is-inside-work-tree'], { cwd: plan.repoRoot });
|
||||
runCommand('tmux', ['-V']);
|
||||
|
||||
if (plan.replaceExisting) {
|
||||
cleanupExisting(plan);
|
||||
} else {
|
||||
const hasSession = spawnSync('tmux', ['has-session', '-t', plan.sessionName], {
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
});
|
||||
if (hasSession.status === 0) {
|
||||
throw new Error(`tmux session already exists: ${plan.sessionName}`);
|
||||
}
|
||||
}
|
||||
|
||||
materializePlan(plan);
|
||||
|
||||
for (const workerPlan of plan.workerPlans) {
|
||||
runCommand('git', workerPlan.gitArgs, { cwd: plan.repoRoot });
|
||||
overlaySeedPaths({
|
||||
repoRoot: plan.repoRoot,
|
||||
seedPaths: workerPlan.seedPaths,
|
||||
worktreePath: workerPlan.worktreePath
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(
|
||||
'tmux',
|
||||
['new-session', '-d', '-s', plan.sessionName, '-n', 'orchestrator', '-c', plan.repoRoot],
|
||||
{ cwd: plan.repoRoot }
|
||||
);
|
||||
runCommand(
|
||||
'tmux',
|
||||
[
|
||||
'send-keys',
|
||||
'-t',
|
||||
plan.sessionName,
|
||||
`printf '%s\\n' 'Session: ${plan.sessionName}' 'Coordination: ${plan.coordinationDir}'`,
|
||||
'C-m'
|
||||
],
|
||||
{ cwd: plan.repoRoot }
|
||||
);
|
||||
|
||||
for (const workerPlan of plan.workerPlans) {
|
||||
const splitResult = runCommand(
|
||||
'tmux',
|
||||
['split-window', '-d', '-P', '-F', '#{pane_id}', '-t', plan.sessionName, '-c', workerPlan.worktreePath],
|
||||
{ cwd: plan.repoRoot }
|
||||
);
|
||||
const paneId = splitResult.stdout.trim();
|
||||
|
||||
if (!paneId) {
|
||||
throw new Error(`tmux split-window did not return a pane id for ${workerPlan.workerName}`);
|
||||
}
|
||||
|
||||
runCommand('tmux', ['select-layout', '-t', plan.sessionName, 'tiled'], { cwd: plan.repoRoot });
|
||||
runCommand('tmux', ['select-pane', '-t', paneId, '-T', workerPlan.workerSlug], {
|
||||
cwd: plan.repoRoot
|
||||
});
|
||||
runCommand(
|
||||
'tmux',
|
||||
[
|
||||
'send-keys',
|
||||
'-t',
|
||||
paneId,
|
||||
`cd ${shellQuote(workerPlan.worktreePath)} && ${workerPlan.launchCommand}`,
|
||||
'C-m'
|
||||
],
|
||||
{ cwd: plan.repoRoot }
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
coordinationDir: plan.coordinationDir,
|
||||
sessionName: plan.sessionName,
|
||||
workerCount: plan.workerPlans.length
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buildOrchestrationPlan,
|
||||
executePlan,
|
||||
materializePlan,
|
||||
normalizeSeedPaths,
|
||||
overlaySeedPaths,
|
||||
renderTemplate,
|
||||
slugify
|
||||
};
|
||||
@@ -1,92 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 3 ]]; then
|
||||
echo "Usage: bash scripts/orchestrate-codex-worker.sh <task-file> <handoff-file> <status-file>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
task_file="$1"
|
||||
handoff_file="$2"
|
||||
status_file="$3"
|
||||
|
||||
timestamp() {
|
||||
date -u +"%Y-%m-%dT%H:%M:%SZ"
|
||||
}
|
||||
|
||||
write_status() {
|
||||
local state="$1"
|
||||
local details="$2"
|
||||
|
||||
cat > "$status_file" <<EOF
|
||||
# Status
|
||||
|
||||
- State: $state
|
||||
- Updated: $(timestamp)
|
||||
- Branch: $(git rev-parse --abbrev-ref HEAD)
|
||||
- Worktree: \`$(pwd)\`
|
||||
|
||||
$details
|
||||
EOF
|
||||
}
|
||||
|
||||
mkdir -p "$(dirname "$handoff_file")" "$(dirname "$status_file")"
|
||||
write_status "running" "- Task file: \`$task_file\`"
|
||||
|
||||
prompt_file="$(mktemp)"
|
||||
output_file="$(mktemp)"
|
||||
cleanup() {
|
||||
rm -f "$prompt_file" "$output_file"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
cat > "$prompt_file" <<EOF
|
||||
You are one worker in an ECC tmux/worktree swarm.
|
||||
|
||||
Rules:
|
||||
- Work only in the current git worktree.
|
||||
- Do not touch sibling worktrees or the parent repo checkout.
|
||||
- Complete the task from the task file below.
|
||||
- Do not spawn subagents or external agents for this task.
|
||||
- Report progress and final results in stdout only.
|
||||
- Do not write handoff or status files yourself; the launcher manages those artifacts.
|
||||
- If you change code or docs, keep the scope narrow and defensible.
|
||||
- In your final response, include exactly these sections:
|
||||
1. Summary
|
||||
2. Files Changed
|
||||
3. Validation
|
||||
4. Remaining Risks
|
||||
|
||||
Task file: $task_file
|
||||
|
||||
$(cat "$task_file")
|
||||
EOF
|
||||
|
||||
if codex exec -p yolo -m gpt-5.4 --color never -C "$(pwd)" -o "$output_file" - < "$prompt_file"; then
|
||||
{
|
||||
echo "# Handoff"
|
||||
echo
|
||||
echo "- Completed: $(timestamp)"
|
||||
echo "- Branch: \`$(git rev-parse --abbrev-ref HEAD)\`"
|
||||
echo "- Worktree: \`$(pwd)\`"
|
||||
echo
|
||||
cat "$output_file"
|
||||
echo
|
||||
echo "## Git Status"
|
||||
echo
|
||||
git status --short
|
||||
} > "$handoff_file"
|
||||
write_status "completed" "- Handoff file: \`$handoff_file\`"
|
||||
else
|
||||
{
|
||||
echo "# Handoff"
|
||||
echo
|
||||
echo "- Failed: $(timestamp)"
|
||||
echo "- Branch: \`$(git rev-parse --abbrev-ref HEAD)\`"
|
||||
echo "- Worktree: \`$(pwd)\`"
|
||||
echo
|
||||
echo "The Codex worker exited with a non-zero status."
|
||||
} > "$handoff_file"
|
||||
write_status "failed" "- Handoff file: \`$handoff_file\`"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,108 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
buildOrchestrationPlan,
|
||||
executePlan,
|
||||
materializePlan
|
||||
} = require('./lib/tmux-worktree-orchestrator');
|
||||
|
||||
function usage() {
|
||||
console.log([
|
||||
'Usage:',
|
||||
' node scripts/orchestrate-worktrees.js <plan.json> [--execute]',
|
||||
' node scripts/orchestrate-worktrees.js <plan.json> [--write-only]',
|
||||
'',
|
||||
'Placeholders supported in launcherCommand:',
|
||||
' {worker_name} {worker_slug} {session_name} {repo_root}',
|
||||
' {worktree_path} {branch_name} {task_file} {handoff_file} {status_file}',
|
||||
'',
|
||||
'Without flags the script prints a dry-run plan only.'
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = argv.slice(2);
|
||||
const planPath = args.find(arg => !arg.startsWith('--'));
|
||||
return {
|
||||
execute: args.includes('--execute'),
|
||||
planPath,
|
||||
writeOnly: args.includes('--write-only')
|
||||
};
|
||||
}
|
||||
|
||||
function loadPlanConfig(planPath) {
|
||||
const absolutePath = path.resolve(planPath);
|
||||
const raw = fs.readFileSync(absolutePath, 'utf8');
|
||||
const config = JSON.parse(raw);
|
||||
config.repoRoot = config.repoRoot || process.cwd();
|
||||
return { absolutePath, config };
|
||||
}
|
||||
|
||||
function printDryRun(plan, absolutePath) {
|
||||
const preview = {
|
||||
planFile: absolutePath,
|
||||
sessionName: plan.sessionName,
|
||||
repoRoot: plan.repoRoot,
|
||||
coordinationDir: plan.coordinationDir,
|
||||
workers: plan.workerPlans.map(worker => ({
|
||||
workerName: worker.workerName,
|
||||
branchName: worker.branchName,
|
||||
worktreePath: worker.worktreePath,
|
||||
seedPaths: worker.seedPaths,
|
||||
taskFilePath: worker.taskFilePath,
|
||||
handoffFilePath: worker.handoffFilePath,
|
||||
launchCommand: worker.launchCommand
|
||||
})),
|
||||
commands: [
|
||||
...plan.workerPlans.map(worker => worker.gitCommand),
|
||||
...plan.tmuxCommands.map(command => [command.cmd, ...command.args].join(' '))
|
||||
]
|
||||
};
|
||||
|
||||
console.log(JSON.stringify(preview, null, 2));
|
||||
}
|
||||
|
||||
function main() {
|
||||
const { execute, planPath, writeOnly } = parseArgs(process.argv);
|
||||
|
||||
if (!planPath) {
|
||||
usage();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const { absolutePath, config } = loadPlanConfig(planPath);
|
||||
const plan = buildOrchestrationPlan(config);
|
||||
|
||||
if (writeOnly) {
|
||||
materializePlan(plan);
|
||||
console.log(`Wrote orchestration files to ${plan.coordinationDir}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!execute) {
|
||||
printDryRun(plan, absolutePath);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = executePlan(plan);
|
||||
console.log([
|
||||
`Started tmux session '${result.sessionName}' with ${result.workerCount} worker panes.`,
|
||||
`Coordination files: ${result.coordinationDir}`,
|
||||
`Attach with: tmux attach -t ${result.sessionName}`
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
try {
|
||||
main();
|
||||
} catch (error) {
|
||||
console.error(`[orchestrate-worktrees] ${error.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { main };
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const { collectSessionSnapshot } = require('./lib/orchestration-session');
|
||||
|
||||
function usage() {
|
||||
console.log([
|
||||
'Usage:',
|
||||
' node scripts/orchestration-status.js <session-name|plan.json> [--write <output.json>]',
|
||||
'',
|
||||
'Examples:',
|
||||
' node scripts/orchestration-status.js workflow-visual-proof',
|
||||
' node scripts/orchestration-status.js .claude/plan/workflow-visual-proof.json',
|
||||
' node scripts/orchestration-status.js .claude/plan/workflow-visual-proof.json --write /tmp/snapshot.json'
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = argv.slice(2);
|
||||
const target = args.find(arg => !arg.startsWith('--'));
|
||||
const writeIndex = args.indexOf('--write');
|
||||
const writePath = writeIndex >= 0 ? args[writeIndex + 1] : null;
|
||||
|
||||
return { target, writePath };
|
||||
}
|
||||
|
||||
function main() {
|
||||
const { target, writePath } = parseArgs(process.argv);
|
||||
|
||||
if (!target) {
|
||||
usage();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const snapshot = collectSessionSnapshot(target, process.cwd());
|
||||
const json = JSON.stringify(snapshot, null, 2);
|
||||
|
||||
if (writePath) {
|
||||
const absoluteWritePath = path.resolve(writePath);
|
||||
fs.mkdirSync(path.dirname(absoluteWritePath), { recursive: true });
|
||||
fs.writeFileSync(absoluteWritePath, json + '\n', 'utf8');
|
||||
}
|
||||
|
||||
console.log(json);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
try {
|
||||
main();
|
||||
} catch (error) {
|
||||
console.error(`[orchestration-status] ${error.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { main };
|
||||
@@ -1,337 +0,0 @@
|
||||
---
|
||||
name: claude-api
|
||||
description: Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Claude API
|
||||
|
||||
Build applications with the Anthropic Claude API and SDKs.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- Building applications that call the Claude API
|
||||
- Code imports `anthropic` (Python) or `@anthropic-ai/sdk` (TypeScript)
|
||||
- User asks about Claude API patterns, tool use, streaming, or vision
|
||||
- Implementing agent workflows with Claude Agent SDK
|
||||
- Optimizing API costs, token usage, or latency
|
||||
|
||||
## Model Selection
|
||||
|
||||
| Model | ID | Best For |
|
||||
|-------|-----|----------|
|
||||
| Opus 4.1 | `claude-opus-4-1` | Complex reasoning, architecture, research |
|
||||
| Sonnet 4 | `claude-sonnet-4-0` | Balanced coding, most development tasks |
|
||||
| Haiku 3.5 | `claude-3-5-haiku-latest` | Fast responses, high-volume, cost-sensitive |
|
||||
|
||||
Default to Sonnet 4 unless the task requires deep reasoning (Opus) or speed/cost optimization (Haiku). For production, prefer pinned snapshot IDs over aliases.
|
||||
|
||||
## Python SDK
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
pip install anthropic
|
||||
```
|
||||
|
||||
### Basic Message
|
||||
|
||||
```python
|
||||
import anthropic
|
||||
|
||||
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from env
|
||||
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=1024,
|
||||
messages=[
|
||||
{"role": "user", "content": "Explain async/await in Python"}
|
||||
]
|
||||
)
|
||||
print(message.content[0].text)
|
||||
```
|
||||
|
||||
### Streaming
|
||||
|
||||
```python
|
||||
with client.messages.stream(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=1024,
|
||||
messages=[{"role": "user", "content": "Write a haiku about coding"}]
|
||||
) as stream:
|
||||
for text in stream.text_stream:
|
||||
print(text, end="", flush=True)
|
||||
```
|
||||
|
||||
### System Prompt
|
||||
|
||||
```python
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=1024,
|
||||
system="You are a senior Python developer. Be concise.",
|
||||
messages=[{"role": "user", "content": "Review this function"}]
|
||||
)
|
||||
```
|
||||
|
||||
## TypeScript SDK
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
npm install @anthropic-ai/sdk
|
||||
```
|
||||
|
||||
### Basic Message
|
||||
|
||||
```typescript
|
||||
import Anthropic from "@anthropic-ai/sdk";
|
||||
|
||||
const client = new Anthropic(); // reads ANTHROPIC_API_KEY from env
|
||||
|
||||
const message = await client.messages.create({
|
||||
model: "claude-sonnet-4-0",
|
||||
max_tokens: 1024,
|
||||
messages: [
|
||||
{ role: "user", content: "Explain async/await in TypeScript" }
|
||||
],
|
||||
});
|
||||
console.log(message.content[0].text);
|
||||
```
|
||||
|
||||
### Streaming
|
||||
|
||||
```typescript
|
||||
const stream = client.messages.stream({
|
||||
model: "claude-sonnet-4-0",
|
||||
max_tokens: 1024,
|
||||
messages: [{ role: "user", content: "Write a haiku" }],
|
||||
});
|
||||
|
||||
for await (const event of stream) {
|
||||
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
|
||||
process.stdout.write(event.delta.text);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Tool Use
|
||||
|
||||
Define tools and let Claude call them:
|
||||
|
||||
```python
|
||||
tools = [
|
||||
{
|
||||
"name": "get_weather",
|
||||
"description": "Get current weather for a location",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {"type": "string", "description": "City name"},
|
||||
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
|
||||
},
|
||||
"required": ["location"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=1024,
|
||||
tools=tools,
|
||||
messages=[{"role": "user", "content": "What's the weather in SF?"}]
|
||||
)
|
||||
|
||||
# Handle tool use response
|
||||
for block in message.content:
|
||||
if block.type == "tool_use":
|
||||
# Execute the tool with block.input
|
||||
result = get_weather(**block.input)
|
||||
# Send result back
|
||||
follow_up = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=1024,
|
||||
tools=tools,
|
||||
messages=[
|
||||
{"role": "user", "content": "What's the weather in SF?"},
|
||||
{"role": "assistant", "content": message.content},
|
||||
{"role": "user", "content": [
|
||||
{"type": "tool_result", "tool_use_id": block.id, "content": str(result)}
|
||||
]}
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Vision
|
||||
|
||||
Send images for analysis:
|
||||
|
||||
```python
|
||||
import base64
|
||||
|
||||
with open("diagram.png", "rb") as f:
|
||||
image_data = base64.standard_b64encode(f.read()).decode("utf-8")
|
||||
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=1024,
|
||||
messages=[{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": image_data}},
|
||||
{"type": "text", "text": "Describe this diagram"}
|
||||
]
|
||||
}]
|
||||
)
|
||||
```
|
||||
|
||||
## Extended Thinking
|
||||
|
||||
For complex reasoning tasks:
|
||||
|
||||
```python
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=16000,
|
||||
thinking={
|
||||
"type": "enabled",
|
||||
"budget_tokens": 10000
|
||||
},
|
||||
messages=[{"role": "user", "content": "Solve this math problem step by step..."}]
|
||||
)
|
||||
|
||||
for block in message.content:
|
||||
if block.type == "thinking":
|
||||
print(f"Thinking: {block.thinking}")
|
||||
elif block.type == "text":
|
||||
print(f"Answer: {block.text}")
|
||||
```
|
||||
|
||||
## Prompt Caching
|
||||
|
||||
Cache large system prompts or context to reduce costs:
|
||||
|
||||
```python
|
||||
message = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=1024,
|
||||
system=[
|
||||
{"type": "text", "text": large_system_prompt, "cache_control": {"type": "ephemeral"}}
|
||||
],
|
||||
messages=[{"role": "user", "content": "Question about the cached context"}]
|
||||
)
|
||||
# Check cache usage
|
||||
print(f"Cache read: {message.usage.cache_read_input_tokens}")
|
||||
print(f"Cache creation: {message.usage.cache_creation_input_tokens}")
|
||||
```
|
||||
|
||||
## Batches API
|
||||
|
||||
Process large volumes asynchronously at 50% cost reduction:
|
||||
|
||||
```python
|
||||
import time
|
||||
|
||||
batch = client.messages.batches.create(
|
||||
requests=[
|
||||
{
|
||||
"custom_id": f"request-{i}",
|
||||
"params": {
|
||||
"model": "claude-sonnet-4-0",
|
||||
"max_tokens": 1024,
|
||||
"messages": [{"role": "user", "content": prompt}]
|
||||
}
|
||||
}
|
||||
for i, prompt in enumerate(prompts)
|
||||
]
|
||||
)
|
||||
|
||||
# Poll for completion
|
||||
while True:
|
||||
status = client.messages.batches.retrieve(batch.id)
|
||||
if status.processing_status == "ended":
|
||||
break
|
||||
time.sleep(30)
|
||||
|
||||
# Get results
|
||||
for result in client.messages.batches.results(batch.id):
|
||||
print(result.result.message.content[0].text)
|
||||
```
|
||||
|
||||
## Claude Agent SDK
|
||||
|
||||
Build multi-step agents:
|
||||
|
||||
```python
|
||||
# Note: Agent SDK API surface may change — check official docs
|
||||
import anthropic
|
||||
|
||||
# Define tools as functions
|
||||
tools = [{
|
||||
"name": "search_codebase",
|
||||
"description": "Search the codebase for relevant code",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {"query": {"type": "string"}},
|
||||
"required": ["query"]
|
||||
}
|
||||
}]
|
||||
|
||||
# Run an agentic loop with tool use
|
||||
client = anthropic.Anthropic()
|
||||
messages = [{"role": "user", "content": "Review the auth module for security issues"}]
|
||||
|
||||
while True:
|
||||
response = client.messages.create(
|
||||
model="claude-sonnet-4-0",
|
||||
max_tokens=4096,
|
||||
tools=tools,
|
||||
messages=messages,
|
||||
)
|
||||
if response.stop_reason == "end_turn":
|
||||
break
|
||||
# Handle tool calls and continue the loop
|
||||
messages.append({"role": "assistant", "content": response.content})
|
||||
# ... execute tools and append tool_result messages
|
||||
```
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
| Strategy | Savings | When to Use |
|
||||
|----------|---------|-------------|
|
||||
| Prompt caching | Up to 90% on cached tokens | Repeated system prompts or context |
|
||||
| Batches API | 50% | Non-time-sensitive bulk processing |
|
||||
| Haiku instead of Sonnet | ~75% | Simple tasks, classification, extraction |
|
||||
| Shorter max_tokens | Variable | When you know output will be short |
|
||||
| Streaming | None (same cost) | Better UX, same price |
|
||||
|
||||
## Error Handling
|
||||
|
||||
```python
|
||||
import time
|
||||
|
||||
from anthropic import APIError, RateLimitError, APIConnectionError
|
||||
|
||||
try:
|
||||
message = client.messages.create(...)
|
||||
except RateLimitError:
|
||||
# Back off and retry
|
||||
time.sleep(60)
|
||||
except APIConnectionError:
|
||||
# Network issue, retry with backoff
|
||||
pass
|
||||
except APIError as e:
|
||||
print(f"API error {e.status_code}: {e.message}")
|
||||
```
|
||||
|
||||
## Environment Setup
|
||||
|
||||
```bash
|
||||
# Required
|
||||
export ANTHROPIC_API_KEY="your-api-key-here"
|
||||
|
||||
# Optional: set default model
|
||||
export ANTHROPIC_MODEL="claude-sonnet-4-0"
|
||||
```
|
||||
|
||||
Never hardcode API keys. Always use environment variables.
|
||||
@@ -82,7 +82,7 @@ If the user chooses niche or core + niche, continue to category selection below
|
||||
|
||||
### 2b: Choose Skill Categories
|
||||
|
||||
There are 35 skills organized into 7 categories. Use `AskUserQuestion` with `multiSelect: true`:
|
||||
There are 27 skills organized into 4 categories. Use `AskUserQuestion` with `multiSelect: true`:
|
||||
|
||||
```
|
||||
Question: "Which skill categories do you want to install?"
|
||||
@@ -90,10 +90,6 @@ Options:
|
||||
- "Framework & Language" — "Django, Spring Boot, Go, Python, Java, Frontend, Backend patterns"
|
||||
- "Database" — "PostgreSQL, ClickHouse, JPA/Hibernate patterns"
|
||||
- "Workflow & Quality" — "TDD, verification, learning, security review, compaction"
|
||||
- "Research & APIs" — "Deep research, Exa search, Claude API patterns"
|
||||
- "Social & Content Distribution" — "X/Twitter API, crossposting alongside content-engine"
|
||||
- "Media Generation" — "fal.ai image/video/audio alongside VideoDB"
|
||||
- "Orchestration" — "dmux multi-agent workflows"
|
||||
- "All skills" — "Install every available skill"
|
||||
```
|
||||
|
||||
@@ -154,34 +150,6 @@ For each selected category, print the full list of skills below and ask the user
|
||||
| `investor-materials` | Pitch decks, one-pagers, investor memos, and financial models |
|
||||
| `investor-outreach` | Personalized investor cold emails, warm intros, and follow-ups |
|
||||
|
||||
**Category: Research & APIs (3 skills)**
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| `deep-research` | Multi-source deep research using firecrawl and exa MCPs with cited reports |
|
||||
| `exa-search` | Neural search via Exa MCP for web, code, company, and people research |
|
||||
| `claude-api` | Anthropic Claude API patterns: Messages, streaming, tool use, vision, batches, Agent SDK |
|
||||
|
||||
**Category: Social & Content Distribution (2 skills)**
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| `x-api` | X/Twitter API integration for posting, threads, search, and analytics |
|
||||
| `crosspost` | Multi-platform content distribution with platform-native adaptation |
|
||||
|
||||
**Category: Media Generation (2 skills)**
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| `fal-ai-media` | Unified AI media generation (image, video, audio) via fal.ai MCP |
|
||||
| `video-editing` | AI-assisted video editing for cutting, structuring, and augmenting real footage |
|
||||
|
||||
**Category: Orchestration (1 skill)**
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| `dmux-workflows` | Multi-agent orchestration using dmux for parallel agent sessions |
|
||||
|
||||
**Standalone**
|
||||
|
||||
| Skill | Description |
|
||||
@@ -262,10 +230,6 @@ Some skills reference others. Verify these dependencies:
|
||||
- `continuous-learning-v2` references `~/.claude/homunculus/` directory
|
||||
- `python-testing` may reference `python-patterns`
|
||||
- `golang-testing` may reference `golang-patterns`
|
||||
- `crosspost` references `content-engine` and `x-api`
|
||||
- `deep-research` references `exa-search` (complementary MCP tools)
|
||||
- `fal-ai-media` references `videodb` (complementary media skill)
|
||||
- `x-api` references `content-engine` and `crosspost`
|
||||
- Language-specific rules reference `common/` counterparts
|
||||
|
||||
### 4d: Report Issues
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
---
|
||||
name: crosspost
|
||||
description: Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Crosspost
|
||||
|
||||
Distribute content across multiple social platforms with platform-native adaptation.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to post content to multiple platforms
|
||||
- Publishing announcements, launches, or updates across social media
|
||||
- Repurposing a post from one platform to others
|
||||
- User says "crosspost", "post everywhere", "share on all platforms", or "distribute this"
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **Never post identical content cross-platform.** Each platform gets a native adaptation.
|
||||
2. **Primary platform first.** Post to the main platform, then adapt for others.
|
||||
3. **Respect platform conventions.** Length limits, formatting, link handling all differ.
|
||||
4. **One idea per post.** If the source content has multiple ideas, split across posts.
|
||||
5. **Attribution matters.** If crossposting someone else's content, credit the source.
|
||||
|
||||
## Platform Specifications
|
||||
|
||||
| Platform | Max Length | Link Handling | Hashtags | Media |
|
||||
|----------|-----------|---------------|----------|-------|
|
||||
| X | 280 chars (4000 for Premium) | Counted in length | Minimal (1-2 max) | Images, video, GIFs |
|
||||
| LinkedIn | 3000 chars | Not counted in length | 3-5 relevant | Images, video, docs, carousels |
|
||||
| Threads | 500 chars | Separate link attachment | None typical | Images, video |
|
||||
| Bluesky | 300 chars | Via facets (rich text) | None (use feeds) | Images |
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Create Source Content
|
||||
|
||||
Start with the core idea. Use `content-engine` skill for high-quality drafts:
|
||||
- Identify the single core message
|
||||
- Determine the primary platform (where the audience is biggest)
|
||||
- Draft the primary platform version first
|
||||
|
||||
### Step 2: Identify Target Platforms
|
||||
|
||||
Ask the user or determine from context:
|
||||
- Which platforms to target
|
||||
- Priority order (primary gets the best version)
|
||||
- Any platform-specific requirements (e.g., LinkedIn needs professional tone)
|
||||
|
||||
### Step 3: Adapt Per Platform
|
||||
|
||||
For each target platform, transform the content:
|
||||
|
||||
**X adaptation:**
|
||||
- Open with a hook, not a summary
|
||||
- Cut to the core insight fast
|
||||
- Keep links out of main body when possible
|
||||
- Use thread format for longer content
|
||||
|
||||
**LinkedIn adaptation:**
|
||||
- Strong first line (visible before "see more")
|
||||
- Short paragraphs with line breaks
|
||||
- Frame around lessons, results, or professional takeaways
|
||||
- More explicit context than X (LinkedIn audience needs framing)
|
||||
|
||||
**Threads adaptation:**
|
||||
- Conversational, casual tone
|
||||
- Shorter than LinkedIn, less compressed than X
|
||||
- Visual-first if possible
|
||||
|
||||
**Bluesky adaptation:**
|
||||
- Direct and concise (300 char limit)
|
||||
- Community-oriented tone
|
||||
- Use feeds/lists for topic targeting instead of hashtags
|
||||
|
||||
### Step 4: Post Primary Platform
|
||||
|
||||
Post to the primary platform first:
|
||||
- Use `x-api` skill for X
|
||||
- Use platform-specific APIs or tools for others
|
||||
- Capture the post URL for cross-referencing
|
||||
|
||||
### Step 5: Post to Secondary Platforms
|
||||
|
||||
Post adapted versions to remaining platforms:
|
||||
- Stagger timing (not all at once — 30-60 min gaps)
|
||||
- Include cross-platform references where appropriate ("longer thread on X" etc.)
|
||||
|
||||
## Content Adaptation Examples
|
||||
|
||||
### Source: Product Launch
|
||||
|
||||
**X version:**
|
||||
```
|
||||
We just shipped [feature].
|
||||
|
||||
[One specific thing it does that's impressive]
|
||||
|
||||
[Link]
|
||||
```
|
||||
|
||||
**LinkedIn version:**
|
||||
```
|
||||
Excited to share: we just launched [feature] at [Company].
|
||||
|
||||
Here's why it matters:
|
||||
|
||||
[2-3 short paragraphs with context]
|
||||
|
||||
[Takeaway for the audience]
|
||||
|
||||
[Link]
|
||||
```
|
||||
|
||||
**Threads version:**
|
||||
```
|
||||
just shipped something cool — [feature]
|
||||
|
||||
[casual explanation of what it does]
|
||||
|
||||
link in bio
|
||||
```
|
||||
|
||||
### Source: Technical Insight
|
||||
|
||||
**X version:**
|
||||
```
|
||||
TIL: [specific technical insight]
|
||||
|
||||
[Why it matters in one sentence]
|
||||
```
|
||||
|
||||
**LinkedIn version:**
|
||||
```
|
||||
A pattern I've been using that's made a real difference:
|
||||
|
||||
[Technical insight with professional framing]
|
||||
|
||||
[How it applies to teams/orgs]
|
||||
|
||||
#relevantHashtag
|
||||
```
|
||||
|
||||
## API Integration
|
||||
|
||||
### Batch Crossposting Service (Example Pattern)
|
||||
If using a crossposting service (e.g., Postbridge, Buffer, or a custom API), the pattern looks like:
|
||||
|
||||
```python
|
||||
import os
|
||||
import requests
|
||||
|
||||
resp = requests.post(
|
||||
"https://your-crosspost-service.example/api/posts",
|
||||
headers={"Authorization": f"Bearer {os.environ['POSTBRIDGE_API_KEY']}"},
|
||||
json={
|
||||
"platforms": ["twitter", "linkedin", "threads"],
|
||||
"content": {
|
||||
"twitter": {"text": x_version},
|
||||
"linkedin": {"text": linkedin_version},
|
||||
"threads": {"text": threads_version}
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Manual Posting
|
||||
Without Postbridge, post to each platform using its native API:
|
||||
- X: Use `x-api` skill patterns
|
||||
- LinkedIn: LinkedIn API v2 with OAuth 2.0
|
||||
- Threads: Threads API (Meta)
|
||||
- Bluesky: AT Protocol API
|
||||
|
||||
## Quality Gate
|
||||
|
||||
Before posting:
|
||||
- [ ] Each platform version reads naturally for that platform
|
||||
- [ ] No identical content across platforms
|
||||
- [ ] Length limits respected
|
||||
- [ ] Links work and are placed appropriately
|
||||
- [ ] Tone matches platform conventions
|
||||
- [ ] Media is sized correctly for each platform
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `content-engine` — Generate platform-native content
|
||||
- `x-api` — X/Twitter API integration
|
||||
@@ -1,155 +0,0 @@
|
||||
---
|
||||
name: deep-research
|
||||
description: Multi-source deep research using firecrawl and exa MCPs. Searches the web, synthesizes findings, and delivers cited reports with source attribution. Use when the user wants thorough research on any topic with evidence and citations.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Deep Research
|
||||
|
||||
Produce thorough, cited research reports from multiple web sources using firecrawl and exa MCP tools.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User asks to research any topic in depth
|
||||
- Competitive analysis, technology evaluation, or market sizing
|
||||
- Due diligence on companies, investors, or technologies
|
||||
- Any question requiring synthesis from multiple sources
|
||||
- User says "research", "deep dive", "investigate", or "what's the current state of"
|
||||
|
||||
## MCP Requirements
|
||||
|
||||
At least one of:
|
||||
- **firecrawl** — `firecrawl_search`, `firecrawl_scrape`, `firecrawl_crawl`
|
||||
- **exa** — `web_search_exa`, `web_search_advanced_exa`, `crawling_exa`
|
||||
|
||||
Both together give the best coverage. Configure in `~/.claude.json` or `~/.codex/config.toml`.
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Understand the Goal
|
||||
|
||||
Ask 1-2 quick clarifying questions:
|
||||
- "What's your goal — learning, making a decision, or writing something?"
|
||||
- "Any specific angle or depth you want?"
|
||||
|
||||
If the user says "just research it" — skip ahead with reasonable defaults.
|
||||
|
||||
### Step 2: Plan the Research
|
||||
|
||||
Break the topic into 3-5 research sub-questions. Example:
|
||||
- Topic: "Impact of AI on healthcare"
|
||||
- What are the main AI applications in healthcare today?
|
||||
- What clinical outcomes have been measured?
|
||||
- What are the regulatory challenges?
|
||||
- What companies are leading this space?
|
||||
- What's the market size and growth trajectory?
|
||||
|
||||
### Step 3: Execute Multi-Source Search
|
||||
|
||||
For EACH sub-question, search using available MCP tools:
|
||||
|
||||
**With firecrawl:**
|
||||
```
|
||||
firecrawl_search(query: "<sub-question keywords>", limit: 8)
|
||||
```
|
||||
|
||||
**With exa:**
|
||||
```
|
||||
web_search_exa(query: "<sub-question keywords>", numResults: 8)
|
||||
web_search_advanced_exa(query: "<keywords>", numResults: 5, startPublishedDate: "2025-01-01")
|
||||
```
|
||||
|
||||
**Search strategy:**
|
||||
- Use 2-3 different keyword variations per sub-question
|
||||
- Mix general and news-focused queries
|
||||
- Aim for 15-30 unique sources total
|
||||
- Prioritize: academic, official, reputable news > blogs > forums
|
||||
|
||||
### Step 4: Deep-Read Key Sources
|
||||
|
||||
For the most promising URLs, fetch full content:
|
||||
|
||||
**With firecrawl:**
|
||||
```
|
||||
firecrawl_scrape(url: "<url>")
|
||||
```
|
||||
|
||||
**With exa:**
|
||||
```
|
||||
crawling_exa(url: "<url>", tokensNum: 5000)
|
||||
```
|
||||
|
||||
Read 3-5 key sources in full for depth. Do not rely only on search snippets.
|
||||
|
||||
### Step 5: Synthesize and Write Report
|
||||
|
||||
Structure the report:
|
||||
|
||||
```markdown
|
||||
# [Topic]: Research Report
|
||||
*Generated: [date] | Sources: [N] | Confidence: [High/Medium/Low]*
|
||||
|
||||
## Executive Summary
|
||||
[3-5 sentence overview of key findings]
|
||||
|
||||
## 1. [First Major Theme]
|
||||
[Findings with inline citations]
|
||||
- Key point ([Source Name](url))
|
||||
- Supporting data ([Source Name](url))
|
||||
|
||||
## 2. [Second Major Theme]
|
||||
...
|
||||
|
||||
## 3. [Third Major Theme]
|
||||
...
|
||||
|
||||
## Key Takeaways
|
||||
- [Actionable insight 1]
|
||||
- [Actionable insight 2]
|
||||
- [Actionable insight 3]
|
||||
|
||||
## Sources
|
||||
1. [Title](url) — [one-line summary]
|
||||
2. ...
|
||||
|
||||
## Methodology
|
||||
Searched [N] queries across web and news. Analyzed [M] sources.
|
||||
Sub-questions investigated: [list]
|
||||
```
|
||||
|
||||
### Step 6: Deliver
|
||||
|
||||
- **Short topics**: Post the full report in chat
|
||||
- **Long reports**: Post the executive summary + key takeaways, save full report to a file
|
||||
|
||||
## Parallel Research with Subagents
|
||||
|
||||
For broad topics, use Claude Code's Task tool to parallelize:
|
||||
|
||||
```
|
||||
Launch 3 research agents in parallel:
|
||||
1. Agent 1: Research sub-questions 1-2
|
||||
2. Agent 2: Research sub-questions 3-4
|
||||
3. Agent 3: Research sub-question 5 + cross-cutting themes
|
||||
```
|
||||
|
||||
Each agent searches, reads sources, and returns findings. The main session synthesizes into the final report.
|
||||
|
||||
## Quality Rules
|
||||
|
||||
1. **Every claim needs a source.** No unsourced assertions.
|
||||
2. **Cross-reference.** If only one source says it, flag it as unverified.
|
||||
3. **Recency matters.** Prefer sources from the last 12 months.
|
||||
4. **Acknowledge gaps.** If you couldn't find good info on a sub-question, say so.
|
||||
5. **No hallucination.** If you don't know, say "insufficient data found."
|
||||
6. **Separate fact from inference.** Label estimates, projections, and opinions clearly.
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
"Research the current state of nuclear fusion energy"
|
||||
"Deep dive into Rust vs Go for backend services in 2026"
|
||||
"Research the best strategies for bootstrapping a SaaS business"
|
||||
"What's happening with the US housing market right now?"
|
||||
"Investigate the competitive landscape for AI code editors"
|
||||
```
|
||||
@@ -1,191 +0,0 @@
|
||||
---
|
||||
name: dmux-workflows
|
||||
description: Multi-agent orchestration using dmux (tmux pane manager for AI agents). Patterns for parallel agent workflows across Claude Code, Codex, OpenCode, and other harnesses. Use when running multiple agent sessions in parallel or coordinating multi-agent development workflows.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# dmux Workflows
|
||||
|
||||
Orchestrate parallel AI agent sessions using dmux, a tmux pane manager for agent harnesses.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- Running multiple agent sessions in parallel
|
||||
- Coordinating work across Claude Code, Codex, and other harnesses
|
||||
- Complex tasks that benefit from divide-and-conquer parallelism
|
||||
- User says "run in parallel", "split this work", "use dmux", or "multi-agent"
|
||||
|
||||
## What is dmux
|
||||
|
||||
dmux is a tmux-based orchestration tool that manages AI agent panes:
|
||||
- Press `n` to create a new pane with a prompt
|
||||
- Press `m` to merge pane output back to the main session
|
||||
- Supports: Claude Code, Codex, OpenCode, Cline, Gemini, Qwen
|
||||
|
||||
**Install:** `npm install -g dmux` or see [github.com/standardagents/dmux](https://github.com/standardagents/dmux)
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Start dmux session
|
||||
dmux
|
||||
|
||||
# Create agent panes (press 'n' in dmux, then type prompt)
|
||||
# Pane 1: "Implement the auth middleware in src/auth/"
|
||||
# Pane 2: "Write tests for the user service"
|
||||
# Pane 3: "Update API documentation"
|
||||
|
||||
# Each pane runs its own agent session
|
||||
# Press 'm' to merge results back
|
||||
```
|
||||
|
||||
## Workflow Patterns
|
||||
|
||||
### Pattern 1: Research + Implement
|
||||
|
||||
Split research and implementation into parallel tracks:
|
||||
|
||||
```
|
||||
Pane 1 (Research): "Research best practices for rate limiting in Node.js.
|
||||
Check current libraries, compare approaches, and write findings to
|
||||
/tmp/rate-limit-research.md"
|
||||
|
||||
Pane 2 (Implement): "Implement rate limiting middleware for our Express API.
|
||||
Start with a basic token bucket, we'll refine after research completes."
|
||||
|
||||
# After Pane 1 completes, merge findings into Pane 2's context
|
||||
```
|
||||
|
||||
### Pattern 2: Multi-File Feature
|
||||
|
||||
Parallelize work across independent files:
|
||||
|
||||
```
|
||||
Pane 1: "Create the database schema and migrations for the billing feature"
|
||||
Pane 2: "Build the billing API endpoints in src/api/billing/"
|
||||
Pane 3: "Create the billing dashboard UI components"
|
||||
|
||||
# Merge all, then do integration in main pane
|
||||
```
|
||||
|
||||
### Pattern 3: Test + Fix Loop
|
||||
|
||||
Run tests in one pane, fix in another:
|
||||
|
||||
```
|
||||
Pane 1 (Watcher): "Run the test suite in watch mode. When tests fail,
|
||||
summarize the failures."
|
||||
|
||||
Pane 2 (Fixer): "Fix failing tests based on the error output from pane 1"
|
||||
```
|
||||
|
||||
### Pattern 4: Cross-Harness
|
||||
|
||||
Use different AI tools for different tasks:
|
||||
|
||||
```
|
||||
Pane 1 (Claude Code): "Review the security of the auth module"
|
||||
Pane 2 (Codex): "Refactor the utility functions for performance"
|
||||
Pane 3 (Claude Code): "Write E2E tests for the checkout flow"
|
||||
```
|
||||
|
||||
### Pattern 5: Code Review Pipeline
|
||||
|
||||
Parallel review perspectives:
|
||||
|
||||
```
|
||||
Pane 1: "Review src/api/ for security vulnerabilities"
|
||||
Pane 2: "Review src/api/ for performance issues"
|
||||
Pane 3: "Review src/api/ for test coverage gaps"
|
||||
|
||||
# Merge all reviews into a single report
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Independent tasks only.** Don't parallelize tasks that depend on each other's output.
|
||||
2. **Clear boundaries.** Each pane should work on distinct files or concerns.
|
||||
3. **Merge strategically.** Review pane output before merging to avoid conflicts.
|
||||
4. **Use git worktrees.** For file-conflict-prone work, use separate worktrees per pane.
|
||||
5. **Resource awareness.** Each pane uses API tokens — keep total panes under 5-6.
|
||||
|
||||
## Git Worktree Integration
|
||||
|
||||
For tasks that touch overlapping files:
|
||||
|
||||
```bash
|
||||
# Create worktrees for isolation
|
||||
git worktree add -b feat/auth ../feature-auth HEAD
|
||||
git worktree add -b feat/billing ../feature-billing HEAD
|
||||
|
||||
# Run agents in separate worktrees
|
||||
# Pane 1: cd ../feature-auth && claude
|
||||
# Pane 2: cd ../feature-billing && claude
|
||||
|
||||
# Merge branches when done
|
||||
git merge feat/auth
|
||||
git merge feat/billing
|
||||
```
|
||||
|
||||
## Complementary Tools
|
||||
|
||||
| Tool | What It Does | When to Use |
|
||||
|------|-------------|-------------|
|
||||
| **dmux** | tmux pane management for agents | Parallel agent sessions |
|
||||
| **Superset** | Terminal IDE for 10+ parallel agents | Large-scale orchestration |
|
||||
| **Claude Code Task tool** | In-process subagent spawning | Programmatic parallelism within a session |
|
||||
| **Codex multi-agent** | Built-in agent roles | Codex-specific parallel work |
|
||||
|
||||
## ECC Helper
|
||||
|
||||
ECC now includes a helper for external tmux-pane orchestration with separate git worktrees:
|
||||
|
||||
```bash
|
||||
node scripts/orchestrate-worktrees.js plan.json --execute
|
||||
```
|
||||
|
||||
Example `plan.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"sessionName": "skill-audit",
|
||||
"baseRef": "HEAD",
|
||||
"launcherCommand": "codex exec --cwd {worktree_path} --task-file {task_file}",
|
||||
"workers": [
|
||||
{ "name": "docs-a", "task": "Fix skills 1-4 and write handoff notes." },
|
||||
{ "name": "docs-b", "task": "Fix skills 5-8 and write handoff notes." }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The helper:
|
||||
- Creates one branch-backed git worktree per worker
|
||||
- Optionally overlays selected `seedPaths` from the main checkout into each worker worktree
|
||||
- Writes per-worker `task.md`, `handoff.md`, and `status.md` files under `.orchestration/<session>/`
|
||||
- Starts a tmux session with one pane per worker
|
||||
- Launches each worker command in its own pane
|
||||
- Leaves the main pane free for the orchestrator
|
||||
|
||||
Use `seedPaths` when workers need access to dirty or untracked local files that are not yet part of `HEAD`, such as local orchestration scripts, draft plans, or docs:
|
||||
|
||||
```json
|
||||
{
|
||||
"sessionName": "workflow-e2e",
|
||||
"seedPaths": [
|
||||
"scripts/orchestrate-worktrees.js",
|
||||
"scripts/lib/tmux-worktree-orchestrator.js",
|
||||
".claude/plan/workflow-e2e-test.json"
|
||||
],
|
||||
"launcherCommand": "bash {repo_root}/scripts/orchestrate-codex-worker.sh {task_file} {handoff_file} {status_file}",
|
||||
"workers": [
|
||||
{ "name": "seed-check", "task": "Verify seeded files are present before starting work." }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **Pane not responding:** Switch to the pane directly or inspect it with `tmux capture-pane -pt <session>:0.<pane-index>`.
|
||||
- **Merge conflicts:** Use git worktrees to isolate file changes per pane.
|
||||
- **High token usage:** Reduce number of parallel panes. Each pane is a full agent session.
|
||||
- **tmux not found:** Install with `brew install tmux` (macOS) or `apt install tmux` (Linux).
|
||||
@@ -1,170 +0,0 @@
|
||||
---
|
||||
name: exa-search
|
||||
description: Neural search via Exa MCP for web, code, and company research. Use when the user needs web search, code examples, company intel, people lookup, or AI-powered deep research with Exa's neural search engine.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Exa Search
|
||||
|
||||
Neural search for web content, code, companies, and people via the Exa MCP server.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User needs current web information or news
|
||||
- Searching for code examples, API docs, or technical references
|
||||
- Researching companies, competitors, or market players
|
||||
- Finding professional profiles or people in a domain
|
||||
- Running background research for any development task
|
||||
- User says "search for", "look up", "find", or "what's the latest on"
|
||||
|
||||
## MCP Requirement
|
||||
|
||||
Exa MCP server must be configured. Add to `~/.claude.json`:
|
||||
|
||||
```json
|
||||
"exa-web-search": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"exa-mcp-server",
|
||||
"tools=web_search_exa,get_code_context_exa,crawling_exa,company_research_exa,linkedin_search_exa,deep_researcher_start,deep_researcher_check"
|
||||
],
|
||||
"env": { "EXA_API_KEY": "YOUR_EXA_API_KEY_HERE" }
|
||||
}
|
||||
```
|
||||
|
||||
Get an API key at [exa.ai](https://exa.ai).
|
||||
If you omit the `tools=...` argument, only a smaller default tool set may be enabled.
|
||||
|
||||
## Core Tools
|
||||
|
||||
### web_search_exa
|
||||
General web search for current information, news, or facts.
|
||||
|
||||
```
|
||||
web_search_exa(query: "latest AI developments 2026", numResults: 5)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `query` | string | required | Search query |
|
||||
| `numResults` | number | 8 | Number of results |
|
||||
|
||||
### web_search_advanced_exa
|
||||
Filtered search with domain and date constraints.
|
||||
|
||||
```
|
||||
web_search_advanced_exa(
|
||||
query: "React Server Components best practices",
|
||||
numResults: 5,
|
||||
includeDomains: ["github.com", "react.dev"],
|
||||
startPublishedDate: "2025-01-01"
|
||||
)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `query` | string | required | Search query |
|
||||
| `numResults` | number | 8 | Number of results |
|
||||
| `includeDomains` | string[] | none | Limit to specific domains |
|
||||
| `excludeDomains` | string[] | none | Exclude specific domains |
|
||||
| `startPublishedDate` | string | none | ISO date filter (start) |
|
||||
| `endPublishedDate` | string | none | ISO date filter (end) |
|
||||
|
||||
### get_code_context_exa
|
||||
Find code examples and documentation from GitHub, Stack Overflow, and docs sites.
|
||||
|
||||
```
|
||||
get_code_context_exa(query: "Python asyncio patterns", tokensNum: 3000)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `query` | string | required | Code or API search query |
|
||||
| `tokensNum` | number | 5000 | Content tokens (1000-50000) |
|
||||
|
||||
### company_research_exa
|
||||
Research companies for business intelligence and news.
|
||||
|
||||
```
|
||||
company_research_exa(companyName: "Anthropic", numResults: 5)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `companyName` | string | required | Company name |
|
||||
| `numResults` | number | 5 | Number of results |
|
||||
|
||||
### linkedin_search_exa
|
||||
Find professional profiles and company-adjacent people research.
|
||||
|
||||
```
|
||||
linkedin_search_exa(query: "AI safety researchers at Anthropic", numResults: 5)
|
||||
```
|
||||
|
||||
### crawling_exa
|
||||
Extract full page content from a URL.
|
||||
|
||||
```
|
||||
crawling_exa(url: "https://example.com/article", tokensNum: 5000)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
| Param | Type | Default | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `url` | string | required | URL to extract |
|
||||
| `tokensNum` | number | 5000 | Content tokens |
|
||||
|
||||
### deep_researcher_start / deep_researcher_check
|
||||
Start an AI research agent that runs asynchronously.
|
||||
|
||||
```
|
||||
# Start research
|
||||
deep_researcher_start(query: "comprehensive analysis of AI code editors in 2026")
|
||||
|
||||
# Check status (returns results when complete)
|
||||
deep_researcher_check(researchId: "<id from start>")
|
||||
```
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
### Quick Lookup
|
||||
```
|
||||
web_search_exa(query: "Node.js 22 new features", numResults: 3)
|
||||
```
|
||||
|
||||
### Code Research
|
||||
```
|
||||
get_code_context_exa(query: "Rust error handling patterns Result type", tokensNum: 3000)
|
||||
```
|
||||
|
||||
### Company Due Diligence
|
||||
```
|
||||
company_research_exa(companyName: "Vercel", numResults: 5)
|
||||
web_search_advanced_exa(query: "Vercel funding valuation 2026", numResults: 3)
|
||||
```
|
||||
|
||||
### Technical Deep Dive
|
||||
```
|
||||
# Start async research
|
||||
deep_researcher_start(query: "WebAssembly component model status and adoption")
|
||||
# ... do other work ...
|
||||
deep_researcher_check(researchId: "<id>")
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Use `web_search_exa` for broad queries, `web_search_advanced_exa` for filtered results
|
||||
- Lower `tokensNum` (1000-2000) for focused code snippets, higher (5000+) for comprehensive context
|
||||
- Combine `company_research_exa` with `web_search_advanced_exa` for thorough company analysis
|
||||
- Use `crawling_exa` to get full content from specific URLs found in search results
|
||||
- `deep_researcher_start` is best for comprehensive topics that benefit from AI synthesis
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `deep-research` — Full research workflow using firecrawl + exa together
|
||||
- `market-research` — Business-oriented research with decision frameworks
|
||||
@@ -1,284 +0,0 @@
|
||||
---
|
||||
name: fal-ai-media
|
||||
description: Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# fal.ai Media Generation
|
||||
|
||||
Generate images, videos, and audio using fal.ai models via MCP.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to generate images from text prompts
|
||||
- Creating videos from text or images
|
||||
- Generating speech, music, or sound effects
|
||||
- Any media generation task
|
||||
- User says "generate image", "create video", "text to speech", "make a thumbnail", or similar
|
||||
|
||||
## MCP Requirement
|
||||
|
||||
fal.ai MCP server must be configured. Add to `~/.claude.json`:
|
||||
|
||||
```json
|
||||
"fal-ai": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "fal-ai-mcp-server"],
|
||||
"env": { "FAL_KEY": "YOUR_FAL_KEY_HERE" }
|
||||
}
|
||||
```
|
||||
|
||||
Get an API key at [fal.ai](https://fal.ai).
|
||||
|
||||
## MCP Tools
|
||||
|
||||
The fal.ai MCP provides these tools:
|
||||
- `search` — Find available models by keyword
|
||||
- `find` — Get model details and parameters
|
||||
- `generate` — Run a model with parameters
|
||||
- `result` — Check async generation status
|
||||
- `status` — Check job status
|
||||
- `cancel` — Cancel a running job
|
||||
- `estimate_cost` — Estimate generation cost
|
||||
- `models` — List popular models
|
||||
- `upload` — Upload files for use as inputs
|
||||
|
||||
---
|
||||
|
||||
## Image Generation
|
||||
|
||||
### Nano Banana 2 (Fast)
|
||||
Best for: quick iterations, drafts, text-to-image, image editing.
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/nano-banana-2",
|
||||
input_data: {
|
||||
"prompt": "a futuristic cityscape at sunset, cyberpunk style",
|
||||
"image_size": "landscape_16_9",
|
||||
"num_images": 1,
|
||||
"seed": 42
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Nano Banana Pro (High Fidelity)
|
||||
Best for: production images, realism, typography, detailed prompts.
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/nano-banana-pro",
|
||||
input_data: {
|
||||
"prompt": "professional product photo of wireless headphones on marble surface, studio lighting",
|
||||
"image_size": "square",
|
||||
"num_images": 1,
|
||||
"guidance_scale": 7.5
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Common Image Parameters
|
||||
|
||||
| Param | Type | Options | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `prompt` | string | required | Describe what you want |
|
||||
| `image_size` | string | `square`, `portrait_4_3`, `landscape_16_9`, `portrait_16_9`, `landscape_4_3` | Aspect ratio |
|
||||
| `num_images` | number | 1-4 | How many to generate |
|
||||
| `seed` | number | any integer | Reproducibility |
|
||||
| `guidance_scale` | number | 1-20 | How closely to follow the prompt (higher = more literal) |
|
||||
|
||||
### Image Editing
|
||||
Use Nano Banana 2 with an input image for inpainting, outpainting, or style transfer:
|
||||
|
||||
```
|
||||
# First upload the source image
|
||||
upload(file_path: "/path/to/image.png")
|
||||
|
||||
# Then generate with image input
|
||||
generate(
|
||||
app_id: "fal-ai/nano-banana-2",
|
||||
input_data: {
|
||||
"prompt": "same scene but in watercolor style",
|
||||
"image_url": "<uploaded_url>",
|
||||
"image_size": "landscape_16_9"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Video Generation
|
||||
|
||||
### Seedance 1.0 Pro (ByteDance)
|
||||
Best for: text-to-video, image-to-video with high motion quality.
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/seedance-1-0-pro",
|
||||
input_data: {
|
||||
"prompt": "a drone flyover of a mountain lake at golden hour, cinematic",
|
||||
"duration": "5s",
|
||||
"aspect_ratio": "16:9",
|
||||
"seed": 42
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Kling Video v3 Pro
|
||||
Best for: text/image-to-video with native audio generation.
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/kling-video/v3/pro",
|
||||
input_data: {
|
||||
"prompt": "ocean waves crashing on a rocky coast, dramatic clouds",
|
||||
"duration": "5s",
|
||||
"aspect_ratio": "16:9"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Veo 3 (Google DeepMind)
|
||||
Best for: video with generated sound, high visual quality.
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/veo-3",
|
||||
input_data: {
|
||||
"prompt": "a bustling Tokyo street market at night, neon signs, crowd noise",
|
||||
"aspect_ratio": "16:9"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Image-to-Video
|
||||
Start from an existing image:
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/seedance-1-0-pro",
|
||||
input_data: {
|
||||
"prompt": "camera slowly zooms out, gentle wind moves the trees",
|
||||
"image_url": "<uploaded_image_url>",
|
||||
"duration": "5s"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Video Parameters
|
||||
|
||||
| Param | Type | Options | Notes |
|
||||
|-------|------|---------|-------|
|
||||
| `prompt` | string | required | Describe the video |
|
||||
| `duration` | string | `"5s"`, `"10s"` | Video length |
|
||||
| `aspect_ratio` | string | `"16:9"`, `"9:16"`, `"1:1"` | Frame ratio |
|
||||
| `seed` | number | any integer | Reproducibility |
|
||||
| `image_url` | string | URL | Source image for image-to-video |
|
||||
|
||||
---
|
||||
|
||||
## Audio Generation
|
||||
|
||||
### CSM-1B (Conversational Speech)
|
||||
Text-to-speech with natural, conversational quality.
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/csm-1b",
|
||||
input_data: {
|
||||
"text": "Hello, welcome to the demo. Let me show you how this works.",
|
||||
"speaker_id": 0
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### ThinkSound (Video-to-Audio)
|
||||
Generate matching audio from video content.
|
||||
|
||||
```
|
||||
generate(
|
||||
app_id: "fal-ai/thinksound",
|
||||
input_data: {
|
||||
"video_url": "<video_url>",
|
||||
"prompt": "ambient forest sounds with birds chirping"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### ElevenLabs (via API, no MCP)
|
||||
For professional voice synthesis, use ElevenLabs directly:
|
||||
|
||||
```python
|
||||
import os
|
||||
import requests
|
||||
|
||||
resp = requests.post(
|
||||
"https://api.elevenlabs.io/v1/text-to-speech/<voice_id>",
|
||||
headers={
|
||||
"xi-api-key": os.environ["ELEVENLABS_API_KEY"],
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
json={
|
||||
"text": "Your text here",
|
||||
"model_id": "eleven_turbo_v2_5",
|
||||
"voice_settings": {"stability": 0.5, "similarity_boost": 0.75}
|
||||
}
|
||||
)
|
||||
with open("output.mp3", "wb") as f:
|
||||
f.write(resp.content)
|
||||
```
|
||||
|
||||
### VideoDB Generative Audio
|
||||
If VideoDB is configured, use its generative audio:
|
||||
|
||||
```python
|
||||
# Voice generation
|
||||
audio = coll.generate_voice(text="Your narration here", voice="alloy")
|
||||
|
||||
# Music generation
|
||||
music = coll.generate_music(prompt="upbeat electronic background music", duration=30)
|
||||
|
||||
# Sound effects
|
||||
sfx = coll.generate_sound_effect(prompt="thunder crack followed by rain")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cost Estimation
|
||||
|
||||
Before generating, check estimated cost:
|
||||
|
||||
```
|
||||
estimate_cost(
|
||||
estimate_type: "unit_price",
|
||||
endpoints: {
|
||||
"fal-ai/nano-banana-pro": {
|
||||
"num_images": 1
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
## Model Discovery
|
||||
|
||||
Find models for specific tasks:
|
||||
|
||||
```
|
||||
search(query: "text to video")
|
||||
find(endpoint_ids: ["fal-ai/seedance-1-0-pro"])
|
||||
models()
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Use `seed` for reproducible results when iterating on prompts
|
||||
- Start with lower-cost models (Nano Banana 2) for prompt iteration, then switch to Pro for finals
|
||||
- For video, keep prompts descriptive but concise — focus on motion and scene
|
||||
- Image-to-video produces more controlled results than pure text-to-video
|
||||
- Check `estimate_cost` before running expensive video generations
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `videodb` — Video processing, editing, and streaming
|
||||
- `video-editing` — AI-powered video editing workflows
|
||||
- `content-engine` — Content creation for social platforms
|
||||
@@ -96,34 +96,6 @@ Understanding what persists helps you compact with confidence:
|
||||
5. **Write before compacting** — Save important context to files or memory before compacting
|
||||
6. **Use `/compact` with a summary** — Add a custom message: `/compact Focus on implementing auth middleware next`
|
||||
|
||||
## Token Optimization Patterns
|
||||
|
||||
### Trigger-Table Lazy Loading
|
||||
Instead of loading full skill content at session start, use a trigger table that maps keywords to skill paths. Skills load only when triggered, reducing baseline context by 50%+:
|
||||
|
||||
| Trigger | Skill | Load When |
|
||||
|---------|-------|-----------|
|
||||
| "test", "tdd", "coverage" | tdd-workflow | User mentions testing |
|
||||
| "security", "auth", "xss" | security-review | Security-related work |
|
||||
| "deploy", "ci/cd" | deployment-patterns | Deployment context |
|
||||
|
||||
### Context Composition Awareness
|
||||
Monitor what's consuming your context window:
|
||||
- **CLAUDE.md files** — Always loaded, keep lean
|
||||
- **Loaded skills** — Each skill adds 1-5K tokens
|
||||
- **Conversation history** — Grows with each exchange
|
||||
- **Tool results** — File reads, search results add bulk
|
||||
|
||||
### Duplicate Instruction Detection
|
||||
Common sources of duplicate context:
|
||||
- Same rules in both `~/.claude/rules/` and project `.claude/rules/`
|
||||
- Skills that repeat CLAUDE.md instructions
|
||||
- Multiple skills covering overlapping domains
|
||||
|
||||
### Context Optimization Tools
|
||||
- `token-optimizer` MCP — Automated 95%+ token reduction via content deduplication
|
||||
- `context-mode` — Context virtualization (315KB to 5.4KB demonstrated)
|
||||
|
||||
## Related
|
||||
|
||||
- [The Longform Guide](https://x.com/affaanmustafa/status/2014040193557471352) — Token optimization section
|
||||
|
||||
@@ -1,310 +0,0 @@
|
||||
---
|
||||
name: video-editing
|
||||
description: AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# Video Editing
|
||||
|
||||
AI-assisted editing for real footage. Not generation from prompts. Editing existing video fast.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to edit, cut, or structure video footage
|
||||
- Turning long recordings into short-form content
|
||||
- Building vlogs, tutorials, or demo videos from raw capture
|
||||
- Adding overlays, subtitles, music, or voiceover to existing video
|
||||
- Reframing video for different platforms (YouTube, TikTok, Instagram)
|
||||
- User says "edit video", "cut this footage", "make a vlog", or "video workflow"
|
||||
|
||||
## Core Thesis
|
||||
|
||||
AI video editing is useful when you stop asking it to create the whole video and start using it to compress, structure, and augment real footage. The value is not generation. The value is compression.
|
||||
|
||||
## The Pipeline
|
||||
|
||||
```
|
||||
Screen Studio / raw footage
|
||||
→ Claude / Codex
|
||||
→ FFmpeg
|
||||
→ Remotion
|
||||
→ ElevenLabs / fal.ai
|
||||
→ Descript or CapCut
|
||||
```
|
||||
|
||||
Each layer has a specific job. Do not skip layers. Do not try to make one tool do everything.
|
||||
|
||||
## Layer 1: Capture (Screen Studio / Raw Footage)
|
||||
|
||||
Collect the source material:
|
||||
- **Screen Studio**: polished screen recordings for app demos, coding sessions, browser workflows
|
||||
- **Raw camera footage**: vlog footage, interviews, event recordings
|
||||
- **Desktop capture via VideoDB**: session recording with real-time context (see `videodb` skill)
|
||||
|
||||
Output: raw files ready for organization.
|
||||
|
||||
## Layer 2: Organization (Claude / Codex)
|
||||
|
||||
Use Claude Code or Codex to:
|
||||
- **Transcribe and label**: generate transcript, identify topics and themes
|
||||
- **Plan structure**: decide what stays, what gets cut, what order works
|
||||
- **Identify dead sections**: find pauses, tangents, repeated takes
|
||||
- **Generate edit decision list**: timestamps for cuts, segments to keep
|
||||
- **Scaffold FFmpeg and Remotion code**: generate the commands and compositions
|
||||
|
||||
```
|
||||
Example prompt:
|
||||
"Here's the transcript of a 4-hour recording. Identify the 8 strongest segments
|
||||
for a 24-minute vlog. Give me FFmpeg cut commands for each segment."
|
||||
```
|
||||
|
||||
This layer is about structure, not final creative taste.
|
||||
|
||||
## Layer 3: Deterministic Cuts (FFmpeg)
|
||||
|
||||
FFmpeg handles the boring but critical work: splitting, trimming, concatenating, and preprocessing.
|
||||
|
||||
### Extract segment by timestamp
|
||||
|
||||
```bash
|
||||
ffmpeg -i raw.mp4 -ss 00:12:30 -to 00:15:45 -c copy segment_01.mp4
|
||||
```
|
||||
|
||||
### Batch cut from edit decision list
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# cuts.txt: start,end,label
|
||||
while IFS=, read -r start end label; do
|
||||
ffmpeg -i raw.mp4 -ss "$start" -to "$end" -c copy "segments/${label}.mp4"
|
||||
done < cuts.txt
|
||||
```
|
||||
|
||||
### Concatenate segments
|
||||
|
||||
```bash
|
||||
# Create file list
|
||||
for f in segments/*.mp4; do echo "file '$f'"; done > concat.txt
|
||||
ffmpeg -f concat -safe 0 -i concat.txt -c copy assembled.mp4
|
||||
```
|
||||
|
||||
### Create proxy for faster editing
|
||||
|
||||
```bash
|
||||
ffmpeg -i raw.mp4 -vf "scale=960:-2" -c:v libx264 -preset ultrafast -crf 28 proxy.mp4
|
||||
```
|
||||
|
||||
### Extract audio for transcription
|
||||
|
||||
```bash
|
||||
ffmpeg -i raw.mp4 -vn -acodec pcm_s16le -ar 16000 audio.wav
|
||||
```
|
||||
|
||||
### Normalize audio levels
|
||||
|
||||
```bash
|
||||
ffmpeg -i segment.mp4 -af loudnorm=I=-16:TP=-1.5:LRA=11 -c:v copy normalized.mp4
|
||||
```
|
||||
|
||||
## Layer 4: Programmable Composition (Remotion)
|
||||
|
||||
Remotion turns editing problems into composable code. Use it for things that traditional editors make painful:
|
||||
|
||||
### When to use Remotion
|
||||
|
||||
- Overlays: text, images, branding, lower thirds
|
||||
- Data visualizations: charts, stats, animated numbers
|
||||
- Motion graphics: transitions, explainer animations
|
||||
- Composable scenes: reusable templates across videos
|
||||
- Product demos: annotated screenshots, UI highlights
|
||||
|
||||
### Basic Remotion composition
|
||||
|
||||
```tsx
|
||||
import { AbsoluteFill, Sequence, Video, useCurrentFrame } from "remotion";
|
||||
|
||||
export const VlogComposition: React.FC = () => {
|
||||
const frame = useCurrentFrame();
|
||||
|
||||
return (
|
||||
<AbsoluteFill>
|
||||
{/* Main footage */}
|
||||
<Sequence from={0} durationInFrames={300}>
|
||||
<Video src="/segments/intro.mp4" />
|
||||
</Sequence>
|
||||
|
||||
{/* Title overlay */}
|
||||
<Sequence from={30} durationInFrames={90}>
|
||||
<AbsoluteFill style={{
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}>
|
||||
<h1 style={{
|
||||
fontSize: 72,
|
||||
color: "white",
|
||||
textShadow: "2px 2px 8px rgba(0,0,0,0.8)",
|
||||
}}>
|
||||
The AI Editing Stack
|
||||
</h1>
|
||||
</AbsoluteFill>
|
||||
</Sequence>
|
||||
|
||||
{/* Next segment */}
|
||||
<Sequence from={300} durationInFrames={450}>
|
||||
<Video src="/segments/demo.mp4" />
|
||||
</Sequence>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### Render output
|
||||
|
||||
```bash
|
||||
npx remotion render src/index.ts VlogComposition output.mp4
|
||||
```
|
||||
|
||||
See the [Remotion docs](https://www.remotion.dev/docs) for detailed patterns and API reference.
|
||||
|
||||
## Layer 5: Generated Assets (ElevenLabs / fal.ai)
|
||||
|
||||
Generate only what you need. Do not generate the whole video.
|
||||
|
||||
### Voiceover with ElevenLabs
|
||||
|
||||
```python
|
||||
import os
|
||||
import requests
|
||||
|
||||
resp = requests.post(
|
||||
f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
|
||||
headers={
|
||||
"xi-api-key": os.environ["ELEVENLABS_API_KEY"],
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
json={
|
||||
"text": "Your narration text here",
|
||||
"model_id": "eleven_turbo_v2_5",
|
||||
"voice_settings": {"stability": 0.5, "similarity_boost": 0.75}
|
||||
}
|
||||
)
|
||||
with open("voiceover.mp3", "wb") as f:
|
||||
f.write(resp.content)
|
||||
```
|
||||
|
||||
### Music and SFX with fal.ai
|
||||
|
||||
Use the `fal-ai-media` skill for:
|
||||
- Background music generation
|
||||
- Sound effects (ThinkSound model for video-to-audio)
|
||||
- Transition sounds
|
||||
|
||||
### Generated visuals with fal.ai
|
||||
|
||||
Use for insert shots, thumbnails, or b-roll that doesn't exist:
|
||||
```
|
||||
generate(app_id: "fal-ai/nano-banana-pro", input_data: {
|
||||
"prompt": "professional thumbnail for tech vlog, dark background, code on screen",
|
||||
"image_size": "landscape_16_9"
|
||||
})
|
||||
```
|
||||
|
||||
### VideoDB generative audio
|
||||
|
||||
If VideoDB is configured:
|
||||
```python
|
||||
voiceover = coll.generate_voice(text="Narration here", voice="alloy")
|
||||
music = coll.generate_music(prompt="lo-fi background for coding vlog", duration=120)
|
||||
sfx = coll.generate_sound_effect(prompt="subtle whoosh transition")
|
||||
```
|
||||
|
||||
## Layer 6: Final Polish (Descript / CapCut)
|
||||
|
||||
The last layer is human. Use a traditional editor for:
|
||||
- **Pacing**: adjust cuts that feel too fast or slow
|
||||
- **Captions**: auto-generated, then manually cleaned
|
||||
- **Color grading**: basic correction and mood
|
||||
- **Final audio mix**: balance voice, music, and SFX levels
|
||||
- **Export**: platform-specific formats and quality settings
|
||||
|
||||
This is where taste lives. AI clears the repetitive work. You make the final calls.
|
||||
|
||||
## Social Media Reframing
|
||||
|
||||
Different platforms need different aspect ratios:
|
||||
|
||||
| Platform | Aspect Ratio | Resolution |
|
||||
|----------|-------------|------------|
|
||||
| YouTube | 16:9 | 1920x1080 |
|
||||
| TikTok / Reels | 9:16 | 1080x1920 |
|
||||
| Instagram Feed | 1:1 | 1080x1080 |
|
||||
| X / Twitter | 16:9 or 1:1 | 1280x720 or 720x720 |
|
||||
|
||||
### Reframe with FFmpeg
|
||||
|
||||
```bash
|
||||
# 16:9 to 9:16 (center crop)
|
||||
ffmpeg -i input.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920" vertical.mp4
|
||||
|
||||
# 16:9 to 1:1 (center crop)
|
||||
ffmpeg -i input.mp4 -vf "crop=ih:ih,scale=1080:1080" square.mp4
|
||||
```
|
||||
|
||||
### Reframe with VideoDB
|
||||
|
||||
```python
|
||||
from videodb import ReframeMode
|
||||
|
||||
# Smart reframe (AI-guided subject tracking)
|
||||
reframed = video.reframe(start=0, end=60, target="vertical", mode=ReframeMode.smart)
|
||||
```
|
||||
|
||||
## Scene Detection and Auto-Cut
|
||||
|
||||
### FFmpeg scene detection
|
||||
|
||||
```bash
|
||||
# Detect scene changes (threshold 0.3 = moderate sensitivity)
|
||||
ffmpeg -i input.mp4 -vf "select='gt(scene,0.3)',showinfo" -vsync vfr -f null - 2>&1 | grep showinfo
|
||||
```
|
||||
|
||||
### Silence detection for auto-cut
|
||||
|
||||
```bash
|
||||
# Find silent segments (useful for cutting dead air)
|
||||
ffmpeg -i input.mp4 -af silencedetect=noise=-30dB:d=2 -f null - 2>&1 | grep silence
|
||||
```
|
||||
|
||||
### Highlight extraction
|
||||
|
||||
Use Claude to analyze transcript + scene timestamps:
|
||||
```
|
||||
"Given this transcript with timestamps and these scene change points,
|
||||
identify the 5 most engaging 30-second clips for social media."
|
||||
```
|
||||
|
||||
## What Each Tool Does Best
|
||||
|
||||
| Tool | Strength | Weakness |
|
||||
|------|----------|----------|
|
||||
| Claude / Codex | Organization, planning, code generation | Not the creative taste layer |
|
||||
| FFmpeg | Deterministic cuts, batch processing, format conversion | No visual editing UI |
|
||||
| Remotion | Programmable overlays, composable scenes, reusable templates | Learning curve for non-devs |
|
||||
| Screen Studio | Polished screen recordings immediately | Only screen capture |
|
||||
| ElevenLabs | Voice, narration, music, SFX | Not the center of the workflow |
|
||||
| Descript / CapCut | Final pacing, captions, polish | Manual, not automatable |
|
||||
|
||||
## Key Principles
|
||||
|
||||
1. **Edit, don't generate.** This workflow is for cutting real footage, not creating from prompts.
|
||||
2. **Structure before style.** Get the story right in Layer 2 before touching anything visual.
|
||||
3. **FFmpeg is the backbone.** Boring but critical. Where long footage becomes manageable.
|
||||
4. **Remotion for repeatability.** If you'll do it more than once, make it a Remotion component.
|
||||
5. **Generate selectively.** Only use AI generation for assets that don't exist, not for everything.
|
||||
6. **Taste is the last layer.** AI clears repetitive work. You make the final creative calls.
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `fal-ai-media` — AI image, video, and audio generation
|
||||
- `videodb` — Server-side video processing, indexing, and streaming
|
||||
- `content-engine` — Platform-native content distribution
|
||||
@@ -1,208 +0,0 @@
|
||||
---
|
||||
name: x-api
|
||||
description: X/Twitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically.
|
||||
origin: ECC
|
||||
---
|
||||
|
||||
# X API
|
||||
|
||||
Programmatic interaction with X (Twitter) for posting, reading, searching, and analytics.
|
||||
|
||||
## When to Activate
|
||||
|
||||
- User wants to post tweets or threads programmatically
|
||||
- Reading timeline, mentions, or user data from X
|
||||
- Searching X for content, trends, or conversations
|
||||
- Building X integrations or bots
|
||||
- Analytics and engagement tracking
|
||||
- User says "post to X", "tweet", "X API", or "Twitter API"
|
||||
|
||||
## Authentication
|
||||
|
||||
### OAuth 2.0 Bearer Token (App-Only)
|
||||
|
||||
Best for: read-heavy operations, search, public data.
|
||||
|
||||
```bash
|
||||
# Environment setup
|
||||
export X_BEARER_TOKEN="your-bearer-token"
|
||||
```
|
||||
|
||||
```python
|
||||
import os
|
||||
import requests
|
||||
|
||||
bearer = os.environ["X_BEARER_TOKEN"]
|
||||
headers = {"Authorization": f"Bearer {bearer}"}
|
||||
|
||||
# Search recent tweets
|
||||
resp = requests.get(
|
||||
"https://api.x.com/2/tweets/search/recent",
|
||||
headers=headers,
|
||||
params={"query": "claude code", "max_results": 10}
|
||||
)
|
||||
tweets = resp.json()
|
||||
```
|
||||
|
||||
### OAuth 1.0a (User Context)
|
||||
|
||||
Required for: posting tweets, managing account, DMs.
|
||||
|
||||
```bash
|
||||
# Environment setup — source before use
|
||||
export X_API_KEY="your-api-key"
|
||||
export X_API_SECRET="your-api-secret"
|
||||
export X_ACCESS_TOKEN="your-access-token"
|
||||
export X_ACCESS_SECRET="your-access-secret"
|
||||
```
|
||||
|
||||
```python
|
||||
import os
|
||||
from requests_oauthlib import OAuth1Session
|
||||
|
||||
oauth = OAuth1Session(
|
||||
os.environ["X_API_KEY"],
|
||||
client_secret=os.environ["X_API_SECRET"],
|
||||
resource_owner_key=os.environ["X_ACCESS_TOKEN"],
|
||||
resource_owner_secret=os.environ["X_ACCESS_SECRET"],
|
||||
)
|
||||
```
|
||||
|
||||
## Core Operations
|
||||
|
||||
### Post a Tweet
|
||||
|
||||
```python
|
||||
resp = oauth.post(
|
||||
"https://api.x.com/2/tweets",
|
||||
json={"text": "Hello from Claude Code"}
|
||||
)
|
||||
resp.raise_for_status()
|
||||
tweet_id = resp.json()["data"]["id"]
|
||||
```
|
||||
|
||||
### Post a Thread
|
||||
|
||||
```python
|
||||
def post_thread(oauth, tweets: list[str]) -> list[str]:
|
||||
ids = []
|
||||
reply_to = None
|
||||
for text in tweets:
|
||||
payload = {"text": text}
|
||||
if reply_to:
|
||||
payload["reply"] = {"in_reply_to_tweet_id": reply_to}
|
||||
resp = oauth.post("https://api.x.com/2/tweets", json=payload)
|
||||
tweet_id = resp.json()["data"]["id"]
|
||||
ids.append(tweet_id)
|
||||
reply_to = tweet_id
|
||||
return ids
|
||||
```
|
||||
|
||||
### Read User Timeline
|
||||
|
||||
```python
|
||||
resp = requests.get(
|
||||
f"https://api.x.com/2/users/{user_id}/tweets",
|
||||
headers=headers,
|
||||
params={
|
||||
"max_results": 10,
|
||||
"tweet.fields": "created_at,public_metrics",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Search Tweets
|
||||
|
||||
```python
|
||||
resp = requests.get(
|
||||
"https://api.x.com/2/tweets/search/recent",
|
||||
headers=headers,
|
||||
params={
|
||||
"query": "from:affaanmustafa -is:retweet",
|
||||
"max_results": 10,
|
||||
"tweet.fields": "public_metrics,created_at",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Get User by Username
|
||||
|
||||
```python
|
||||
resp = requests.get(
|
||||
"https://api.x.com/2/users/by/username/affaanmustafa",
|
||||
headers=headers,
|
||||
params={"user.fields": "public_metrics,description,created_at"}
|
||||
)
|
||||
```
|
||||
|
||||
### Upload Media and Post
|
||||
|
||||
```python
|
||||
# Media upload uses v1.1 endpoint
|
||||
|
||||
# Step 1: Upload media
|
||||
media_resp = oauth.post(
|
||||
"https://upload.twitter.com/1.1/media/upload.json",
|
||||
files={"media": open("image.png", "rb")}
|
||||
)
|
||||
media_id = media_resp.json()["media_id_string"]
|
||||
|
||||
# Step 2: Post with media
|
||||
resp = oauth.post(
|
||||
"https://api.x.com/2/tweets",
|
||||
json={"text": "Check this out", "media": {"media_ids": [media_id]}}
|
||||
)
|
||||
```
|
||||
|
||||
## Rate Limits
|
||||
|
||||
X API rate limits vary by endpoint, auth method, and account tier, and they change over time. Always:
|
||||
- Check the current X developer docs before hardcoding assumptions
|
||||
- Read `x-rate-limit-remaining` and `x-rate-limit-reset` headers at runtime
|
||||
- Back off automatically instead of relying on static tables in code
|
||||
|
||||
```python
|
||||
import time
|
||||
|
||||
remaining = int(resp.headers.get("x-rate-limit-remaining", 0))
|
||||
if remaining < 5:
|
||||
reset = int(resp.headers.get("x-rate-limit-reset", 0))
|
||||
wait = max(0, reset - int(time.time()))
|
||||
print(f"Rate limit approaching. Resets in {wait}s")
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```python
|
||||
resp = oauth.post("https://api.x.com/2/tweets", json={"text": content})
|
||||
if resp.status_code == 201:
|
||||
return resp.json()["data"]["id"]
|
||||
elif resp.status_code == 429:
|
||||
reset = int(resp.headers["x-rate-limit-reset"])
|
||||
raise Exception(f"Rate limited. Resets at {reset}")
|
||||
elif resp.status_code == 403:
|
||||
raise Exception(f"Forbidden: {resp.json().get('detail', 'check permissions')}")
|
||||
else:
|
||||
raise Exception(f"X API error {resp.status_code}: {resp.text}")
|
||||
```
|
||||
|
||||
## Security
|
||||
|
||||
- **Never hardcode tokens.** Use environment variables or `.env` files.
|
||||
- **Never commit `.env` files.** Add to `.gitignore`.
|
||||
- **Rotate tokens** if exposed. Regenerate at developer.x.com.
|
||||
- **Use read-only tokens** when write access is not needed.
|
||||
- **Store OAuth secrets securely** — not in source code or logs.
|
||||
|
||||
## Integration with Content Engine
|
||||
|
||||
Use `content-engine` skill to generate platform-native content, then post via X API:
|
||||
1. Generate content with content-engine (X platform format)
|
||||
2. Validate length (280 chars for single tweet)
|
||||
3. Post via X API using patterns above
|
||||
4. Track engagement via public_metrics
|
||||
|
||||
## Related Skills
|
||||
|
||||
- `content-engine` — Generate platform-native content for X
|
||||
- `crosspost` — Distribute content across X, LinkedIn, and other platforms
|
||||
@@ -360,30 +360,22 @@ async function runTests() {
|
||||
|
||||
if (
|
||||
await asyncTest('creates or updates session file', async () => {
|
||||
const isoHome = path.join(os.tmpdir(), `ecc-session-create-${Date.now()}`);
|
||||
// Run the script
|
||||
await runScript(path.join(scriptsDir, 'session-end.js'));
|
||||
|
||||
try {
|
||||
await runScript(path.join(scriptsDir, 'session-end.js'), '', {
|
||||
HOME: isoHome,
|
||||
USERPROFILE: isoHome
|
||||
});
|
||||
// Check if session file was created
|
||||
// Note: Without CLAUDE_SESSION_ID, falls back to project name (not 'default')
|
||||
// Use local time to match the script's getDateString() function
|
||||
const sessionsDir = path.join(os.homedir(), '.claude', 'sessions');
|
||||
const now = new Date();
|
||||
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
|
||||
// Check if session file was created
|
||||
// Note: Without CLAUDE_SESSION_ID, falls back to project/worktree name (not 'default')
|
||||
// Use local time to match the script's getDateString() function
|
||||
const sessionsDir = path.join(isoHome, '.claude', 'sessions');
|
||||
const now = new Date();
|
||||
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
// Get the expected session ID (project name fallback)
|
||||
const utils = require('../../scripts/lib/utils');
|
||||
const expectedId = utils.getSessionIdShort();
|
||||
const sessionFile = path.join(sessionsDir, `${today}-${expectedId}-session.tmp`);
|
||||
|
||||
// Get the expected session ID (project name fallback)
|
||||
const utils = require('../../scripts/lib/utils');
|
||||
const expectedId = utils.getSessionIdShort();
|
||||
const sessionFile = path.join(sessionsDir, `${today}-${expectedId}-session.tmp`);
|
||||
|
||||
assert.ok(fs.existsSync(sessionFile), `Session file should exist: ${sessionFile}`);
|
||||
} finally {
|
||||
fs.rmSync(isoHome, { recursive: true, force: true });
|
||||
}
|
||||
assert.ok(fs.existsSync(sessionFile), `Session file should exist: ${sessionFile}`);
|
||||
})
|
||||
)
|
||||
passed++;
|
||||
@@ -412,39 +404,6 @@ async function runTests() {
|
||||
passed++;
|
||||
else failed++;
|
||||
|
||||
if (
|
||||
await asyncTest('writes project, branch, and worktree metadata into new session files', async () => {
|
||||
const isoHome = path.join(os.tmpdir(), `ecc-session-metadata-${Date.now()}`);
|
||||
const testSessionId = 'test-session-meta1234';
|
||||
const expectedShortId = testSessionId.slice(-8);
|
||||
const topLevel = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout.trim();
|
||||
const branch = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8' }).stdout.trim();
|
||||
const project = path.basename(topLevel);
|
||||
|
||||
try {
|
||||
const result = await runScript(path.join(scriptsDir, 'session-end.js'), '', {
|
||||
HOME: isoHome,
|
||||
USERPROFILE: isoHome,
|
||||
CLAUDE_SESSION_ID: testSessionId
|
||||
});
|
||||
assert.strictEqual(result.code, 0, 'Hook should exit 0');
|
||||
|
||||
const now = new Date();
|
||||
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
const sessionFile = path.join(isoHome, '.claude', 'sessions', `${today}-${expectedShortId}-session.tmp`);
|
||||
const content = fs.readFileSync(sessionFile, 'utf8');
|
||||
|
||||
assert.ok(content.includes(`**Project:** ${project}`), 'Should persist project metadata');
|
||||
assert.ok(content.includes(`**Branch:** ${branch}`), 'Should persist branch metadata');
|
||||
assert.ok(content.includes(`**Worktree:** ${process.cwd()}`), 'Should persist worktree metadata');
|
||||
} finally {
|
||||
fs.rmSync(isoHome, { recursive: true, force: true });
|
||||
}
|
||||
})
|
||||
)
|
||||
passed++;
|
||||
else failed++;
|
||||
|
||||
// pre-compact.js tests
|
||||
console.log('\npre-compact.js:');
|
||||
|
||||
@@ -1259,10 +1218,7 @@ async function runTests() {
|
||||
fs.writeFileSync(transcriptPath, lines.join('\n'));
|
||||
|
||||
const stdinJson = JSON.stringify({ transcript_path: transcriptPath });
|
||||
const result = await runScript(path.join(scriptsDir, 'session-end.js'), stdinJson, {
|
||||
HOME: testDir,
|
||||
USERPROFILE: testDir
|
||||
});
|
||||
const result = await runScript(path.join(scriptsDir, 'session-end.js'), stdinJson);
|
||||
assert.strictEqual(result.code, 0);
|
||||
// Session file should contain summary with tools used
|
||||
assert.ok(result.stderr.includes('Created session file') || result.stderr.includes('Updated session file'), 'Should create/update session file');
|
||||
@@ -2492,42 +2448,6 @@ async function runTests() {
|
||||
passed++;
|
||||
else failed++;
|
||||
|
||||
if (
|
||||
await asyncTest('normalizes existing session headers with project, branch, and worktree metadata', async () => {
|
||||
const testDir = createTestDir();
|
||||
const sessionsDir = path.join(testDir, '.claude', 'sessions');
|
||||
fs.mkdirSync(sessionsDir, { recursive: true });
|
||||
|
||||
const utils = require('../../scripts/lib/utils');
|
||||
const today = utils.getDateString();
|
||||
const shortId = 'update04';
|
||||
const sessionFile = path.join(sessionsDir, `${today}-${shortId}-session.tmp`);
|
||||
const branch = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8' }).stdout.trim();
|
||||
const project = path.basename(spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout.trim());
|
||||
|
||||
fs.writeFileSync(
|
||||
sessionFile,
|
||||
`# Session: ${today}\n**Date:** ${today}\n**Started:** 09:00\n**Last Updated:** 09:00\n\n---\n\n## Current State\n\n[Session context goes here]\n`
|
||||
);
|
||||
|
||||
const result = await runScript(path.join(scriptsDir, 'session-end.js'), '', {
|
||||
HOME: testDir,
|
||||
USERPROFILE: testDir,
|
||||
CLAUDE_SESSION_ID: `session-${shortId}`
|
||||
});
|
||||
assert.strictEqual(result.code, 0);
|
||||
|
||||
const updated = fs.readFileSync(sessionFile, 'utf8');
|
||||
assert.ok(updated.includes(`**Project:** ${project}`), 'Should inject project metadata into existing headers');
|
||||
assert.ok(updated.includes(`**Branch:** ${branch}`), 'Should inject branch metadata into existing headers');
|
||||
assert.ok(updated.includes(`**Worktree:** ${process.cwd()}`), 'Should inject worktree metadata into existing headers');
|
||||
|
||||
cleanupTestDir(testDir);
|
||||
})
|
||||
)
|
||||
passed++;
|
||||
else failed++;
|
||||
|
||||
if (
|
||||
await asyncTest('replaces blank template with summary when updating existing file', async () => {
|
||||
const testDir = createTestDir();
|
||||
@@ -3895,8 +3815,6 @@ async function runTests() {
|
||||
|
||||
try {
|
||||
const result = await runScript(path.join(scriptsDir, 'session-end.js'), oversizedPayload, {
|
||||
HOME: testDir,
|
||||
USERPROFILE: testDir,
|
||||
CLAUDE_TRANSCRIPT_PATH: transcriptPath
|
||||
});
|
||||
assert.strictEqual(result.code, 0, 'Should exit 0 even with oversized stdin');
|
||||
|
||||
@@ -1,214 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
buildSessionSnapshot,
|
||||
loadWorkerSnapshots,
|
||||
parseWorkerHandoff,
|
||||
parseWorkerStatus,
|
||||
parseWorkerTask,
|
||||
resolveSnapshotTarget
|
||||
} = require('../../scripts/lib/orchestration-session');
|
||||
|
||||
console.log('=== Testing orchestration-session.js ===\n');
|
||||
|
||||
let passed = 0;
|
||||
let failed = 0;
|
||||
|
||||
function test(desc, fn) {
|
||||
try {
|
||||
fn();
|
||||
console.log(` ✓ ${desc}`);
|
||||
passed++;
|
||||
} catch (error) {
|
||||
console.log(` ✗ ${desc}: ${error.message}`);
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
test('parseWorkerStatus extracts structured status fields', () => {
|
||||
const status = parseWorkerStatus([
|
||||
'# Status',
|
||||
'',
|
||||
'- State: completed',
|
||||
'- Updated: 2026-03-12T14:09:15Z',
|
||||
'- Branch: feature-branch',
|
||||
'- Worktree: `/tmp/worktree`',
|
||||
'',
|
||||
'- Handoff file: `/tmp/handoff.md`'
|
||||
].join('\n'));
|
||||
|
||||
assert.deepStrictEqual(status, {
|
||||
state: 'completed',
|
||||
updated: '2026-03-12T14:09:15Z',
|
||||
branch: 'feature-branch',
|
||||
worktree: '/tmp/worktree',
|
||||
taskFile: null,
|
||||
handoffFile: '/tmp/handoff.md'
|
||||
});
|
||||
});
|
||||
|
||||
test('parseWorkerTask extracts objective and seeded overlays', () => {
|
||||
const task = parseWorkerTask([
|
||||
'# Worker Task',
|
||||
'',
|
||||
'## Seeded Local Overlays',
|
||||
'- `scripts/orchestrate-worktrees.js`',
|
||||
'- `commands/orchestrate.md`',
|
||||
'',
|
||||
'## Objective',
|
||||
'Verify seeded files and summarize status.'
|
||||
].join('\n'));
|
||||
|
||||
assert.deepStrictEqual(task.seedPaths, [
|
||||
'scripts/orchestrate-worktrees.js',
|
||||
'commands/orchestrate.md'
|
||||
]);
|
||||
assert.strictEqual(task.objective, 'Verify seeded files and summarize status.');
|
||||
});
|
||||
|
||||
test('parseWorkerHandoff extracts summary, validation, and risks', () => {
|
||||
const handoff = parseWorkerHandoff([
|
||||
'# Handoff',
|
||||
'',
|
||||
'## Summary',
|
||||
'- Worker completed successfully',
|
||||
'',
|
||||
'## Validation',
|
||||
'- Ran tests',
|
||||
'',
|
||||
'## Remaining Risks',
|
||||
'- No runtime screenshot'
|
||||
].join('\n'));
|
||||
|
||||
assert.deepStrictEqual(handoff.summary, ['Worker completed successfully']);
|
||||
assert.deepStrictEqual(handoff.validation, ['Ran tests']);
|
||||
assert.deepStrictEqual(handoff.remainingRisks, ['No runtime screenshot']);
|
||||
});
|
||||
|
||||
test('parseWorkerHandoff also supports bold section headers', () => {
|
||||
const handoff = parseWorkerHandoff([
|
||||
'# Handoff',
|
||||
'',
|
||||
'**Summary**',
|
||||
'- Worker completed successfully',
|
||||
'',
|
||||
'**Validation**',
|
||||
'- Ran tests',
|
||||
'',
|
||||
'**Remaining Risks**',
|
||||
'- No runtime screenshot'
|
||||
].join('\n'));
|
||||
|
||||
assert.deepStrictEqual(handoff.summary, ['Worker completed successfully']);
|
||||
assert.deepStrictEqual(handoff.validation, ['Ran tests']);
|
||||
assert.deepStrictEqual(handoff.remainingRisks, ['No runtime screenshot']);
|
||||
});
|
||||
|
||||
test('loadWorkerSnapshots reads coordination worker directories', () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-orch-session-'));
|
||||
const coordinationDir = path.join(tempRoot, 'coordination');
|
||||
const workerDir = path.join(coordinationDir, 'seed-check');
|
||||
const proofDir = path.join(coordinationDir, 'proof');
|
||||
fs.mkdirSync(workerDir, { recursive: true });
|
||||
fs.mkdirSync(proofDir, { recursive: true });
|
||||
|
||||
try {
|
||||
fs.writeFileSync(path.join(workerDir, 'status.md'), [
|
||||
'# Status',
|
||||
'',
|
||||
'- State: running',
|
||||
'- Branch: seed-branch',
|
||||
'- Worktree: `/tmp/seed-worktree`'
|
||||
].join('\n'));
|
||||
fs.writeFileSync(path.join(workerDir, 'task.md'), [
|
||||
'# Worker Task',
|
||||
'',
|
||||
'## Objective',
|
||||
'Inspect seed paths.'
|
||||
].join('\n'));
|
||||
fs.writeFileSync(path.join(workerDir, 'handoff.md'), [
|
||||
'# Handoff',
|
||||
'',
|
||||
'## Summary',
|
||||
'- Pending'
|
||||
].join('\n'));
|
||||
|
||||
const workers = loadWorkerSnapshots(coordinationDir);
|
||||
assert.strictEqual(workers.length, 1);
|
||||
assert.strictEqual(workers[0].workerSlug, 'seed-check');
|
||||
assert.strictEqual(workers[0].status.branch, 'seed-branch');
|
||||
assert.strictEqual(workers[0].task.objective, 'Inspect seed paths.');
|
||||
} finally {
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('buildSessionSnapshot merges tmux panes with worker metadata', () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-orch-snapshot-'));
|
||||
const coordinationDir = path.join(tempRoot, 'coordination');
|
||||
const workerDir = path.join(coordinationDir, 'seed-check');
|
||||
fs.mkdirSync(workerDir, { recursive: true });
|
||||
|
||||
try {
|
||||
fs.writeFileSync(path.join(workerDir, 'status.md'), '- State: completed\n- Branch: seed-branch\n');
|
||||
fs.writeFileSync(path.join(workerDir, 'task.md'), '## Objective\nInspect seed paths.\n');
|
||||
fs.writeFileSync(path.join(workerDir, 'handoff.md'), '## Summary\n- ok\n');
|
||||
|
||||
const snapshot = buildSessionSnapshot({
|
||||
sessionName: 'workflow-visual-proof',
|
||||
coordinationDir,
|
||||
panes: [
|
||||
{
|
||||
paneId: '%95',
|
||||
windowIndex: 1,
|
||||
paneIndex: 2,
|
||||
title: 'seed-check',
|
||||
currentCommand: 'codex',
|
||||
currentPath: '/tmp/worktree',
|
||||
active: false,
|
||||
dead: false,
|
||||
pid: 1234
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
assert.strictEqual(snapshot.sessionActive, true);
|
||||
assert.strictEqual(snapshot.workerCount, 1);
|
||||
assert.strictEqual(snapshot.workerStates.completed, 1);
|
||||
assert.strictEqual(snapshot.workers[0].pane.paneId, '%95');
|
||||
} finally {
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('resolveSnapshotTarget handles plan files and direct session names', () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-orch-target-'));
|
||||
const repoRoot = path.join(tempRoot, 'repo');
|
||||
fs.mkdirSync(repoRoot, { recursive: true });
|
||||
const planPath = path.join(repoRoot, 'plan.json');
|
||||
fs.writeFileSync(planPath, JSON.stringify({
|
||||
sessionName: 'workflow-visual-proof',
|
||||
repoRoot,
|
||||
coordinationRoot: path.join(repoRoot, '.claude', 'orchestration')
|
||||
}));
|
||||
|
||||
try {
|
||||
const fromPlan = resolveSnapshotTarget(planPath, repoRoot);
|
||||
assert.strictEqual(fromPlan.targetType, 'plan');
|
||||
assert.strictEqual(fromPlan.sessionName, 'workflow-visual-proof');
|
||||
|
||||
const fromSession = resolveSnapshotTarget('workflow-visual-proof', repoRoot);
|
||||
assert.strictEqual(fromSession.targetType, 'session');
|
||||
assert.ok(fromSession.coordinationDir.endsWith(path.join('.claude', 'orchestration', 'workflow-visual-proof')));
|
||||
} finally {
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`\n=== Results: ${passed} passed, ${failed} failed ===`);
|
||||
if (failed > 0) process.exit(1);
|
||||
@@ -94,9 +94,6 @@ function runTests() {
|
||||
**Date:** 2026-02-01
|
||||
**Started:** 10:30
|
||||
**Last Updated:** 14:45
|
||||
**Project:** everything-claude-code
|
||||
**Branch:** feature/session-metadata
|
||||
**Worktree:** /tmp/ecc-worktree
|
||||
|
||||
### Completed
|
||||
- [x] Set up project
|
||||
@@ -117,9 +114,6 @@ src/main.ts
|
||||
assert.strictEqual(meta.date, '2026-02-01');
|
||||
assert.strictEqual(meta.started, '10:30');
|
||||
assert.strictEqual(meta.lastUpdated, '14:45');
|
||||
assert.strictEqual(meta.project, 'everything-claude-code');
|
||||
assert.strictEqual(meta.branch, 'feature/session-metadata');
|
||||
assert.strictEqual(meta.worktree, '/tmp/ecc-worktree');
|
||||
assert.strictEqual(meta.completed.length, 2);
|
||||
assert.strictEqual(meta.completed[0], 'Set up project');
|
||||
assert.strictEqual(meta.inProgress.length, 1);
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
slugify,
|
||||
renderTemplate,
|
||||
buildOrchestrationPlan,
|
||||
materializePlan,
|
||||
normalizeSeedPaths,
|
||||
overlaySeedPaths
|
||||
} = require('../../scripts/lib/tmux-worktree-orchestrator');
|
||||
|
||||
console.log('=== Testing tmux-worktree-orchestrator.js ===\n');
|
||||
|
||||
let passed = 0;
|
||||
let failed = 0;
|
||||
|
||||
function test(desc, fn) {
|
||||
try {
|
||||
fn();
|
||||
console.log(` ✓ ${desc}`);
|
||||
passed++;
|
||||
} catch (error) {
|
||||
console.log(` ✗ ${desc}: ${error.message}`);
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Helpers:');
|
||||
test('slugify normalizes mixed punctuation and casing', () => {
|
||||
assert.strictEqual(slugify('Feature Audit: Docs + Tmux'), 'feature-audit-docs-tmux');
|
||||
});
|
||||
|
||||
test('renderTemplate replaces supported placeholders', () => {
|
||||
const rendered = renderTemplate('run {worker_name} in {worktree_path}', {
|
||||
worker_name: 'Docs Fixer',
|
||||
worktree_path: '/tmp/repo-worker'
|
||||
});
|
||||
assert.strictEqual(rendered, 'run Docs Fixer in /tmp/repo-worker');
|
||||
});
|
||||
|
||||
test('renderTemplate rejects unknown placeholders', () => {
|
||||
assert.throws(
|
||||
() => renderTemplate('missing {unknown}', { worker_name: 'docs' }),
|
||||
/Unknown template variable/
|
||||
);
|
||||
});
|
||||
|
||||
console.log('\nPlan generation:');
|
||||
test('buildOrchestrationPlan creates worktrees, branches, and tmux commands', () => {
|
||||
const repoRoot = path.join('/tmp', 'ecc');
|
||||
const plan = buildOrchestrationPlan({
|
||||
repoRoot,
|
||||
sessionName: 'Skill Audit',
|
||||
baseRef: 'main',
|
||||
launcherCommand: 'codex exec --cwd {worktree_path} --task-file {task_file}',
|
||||
workers: [
|
||||
{ name: 'Docs A', task: 'Fix skills 1-4' },
|
||||
{ name: 'Docs B', task: 'Fix skills 5-8' }
|
||||
]
|
||||
});
|
||||
|
||||
assert.strictEqual(plan.sessionName, 'skill-audit');
|
||||
assert.strictEqual(plan.workerPlans.length, 2);
|
||||
assert.strictEqual(plan.workerPlans[0].branchName, 'orchestrator-skill-audit-docs-a');
|
||||
assert.strictEqual(plan.workerPlans[1].branchName, 'orchestrator-skill-audit-docs-b');
|
||||
assert.deepStrictEqual(
|
||||
plan.workerPlans[0].gitArgs.slice(0, 4),
|
||||
['worktree', 'add', '-b', 'orchestrator-skill-audit-docs-a'],
|
||||
'Should create branch-backed worktrees'
|
||||
);
|
||||
assert.ok(
|
||||
plan.workerPlans[0].worktreePath.endsWith(path.join('ecc-skill-audit-docs-a')),
|
||||
'Should create sibling worktree path'
|
||||
);
|
||||
assert.ok(
|
||||
plan.workerPlans[0].taskFilePath.endsWith(path.join('.orchestration', 'skill-audit', 'docs-a', 'task.md')),
|
||||
'Should create per-worker task file'
|
||||
);
|
||||
assert.ok(
|
||||
plan.workerPlans[0].handoffFilePath.endsWith(path.join('.orchestration', 'skill-audit', 'docs-a', 'handoff.md')),
|
||||
'Should create per-worker handoff file'
|
||||
);
|
||||
assert.ok(
|
||||
plan.workerPlans[0].launchCommand.includes(plan.workerPlans[0].taskFilePath),
|
||||
'Launch command should interpolate task file'
|
||||
);
|
||||
assert.ok(
|
||||
plan.workerPlans[0].launchCommand.includes(plan.workerPlans[0].worktreePath),
|
||||
'Launch command should interpolate worktree path'
|
||||
);
|
||||
assert.ok(
|
||||
plan.tmuxCommands.some(command => command.args.includes('split-window')),
|
||||
'Should include tmux split commands'
|
||||
);
|
||||
assert.ok(
|
||||
plan.tmuxCommands.some(command => command.args.includes('select-layout')),
|
||||
'Should include tiled layout command'
|
||||
);
|
||||
});
|
||||
|
||||
test('buildOrchestrationPlan requires at least one worker', () => {
|
||||
assert.throws(
|
||||
() => buildOrchestrationPlan({
|
||||
repoRoot: '/tmp/ecc',
|
||||
sessionName: 'empty',
|
||||
launcherCommand: 'codex exec --task-file {task_file}',
|
||||
workers: []
|
||||
}),
|
||||
/at least one worker/
|
||||
);
|
||||
});
|
||||
|
||||
test('buildOrchestrationPlan normalizes global and worker seed paths', () => {
|
||||
const plan = buildOrchestrationPlan({
|
||||
repoRoot: '/tmp/ecc',
|
||||
sessionName: 'seeded',
|
||||
launcherCommand: 'echo run',
|
||||
seedPaths: ['scripts/orchestrate-worktrees.js', './.claude/plan/workflow-e2e-test.json'],
|
||||
workers: [
|
||||
{
|
||||
name: 'Docs',
|
||||
task: 'Update docs',
|
||||
seedPaths: ['commands/multi-workflow.md']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(plan.workerPlans[0].seedPaths, [
|
||||
'scripts/orchestrate-worktrees.js',
|
||||
'.claude/plan/workflow-e2e-test.json',
|
||||
'commands/multi-workflow.md'
|
||||
]);
|
||||
});
|
||||
|
||||
test('normalizeSeedPaths rejects paths outside the repo root', () => {
|
||||
assert.throws(
|
||||
() => normalizeSeedPaths(['../outside.txt'], '/tmp/ecc'),
|
||||
/inside repoRoot/
|
||||
);
|
||||
});
|
||||
|
||||
test('materializePlan keeps worker instructions inside the worktree boundary', () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-orchestrator-test-'));
|
||||
|
||||
try {
|
||||
const plan = buildOrchestrationPlan({
|
||||
repoRoot: tempRoot,
|
||||
coordinationRoot: path.join(tempRoot, '.claude', 'orchestration'),
|
||||
sessionName: 'Workflow E2E',
|
||||
launcherCommand: 'bash {repo_root}/scripts/orchestrate-codex-worker.sh {task_file} {handoff_file} {status_file}',
|
||||
workers: [{ name: 'Docs', task: 'Update the workflow docs.' }]
|
||||
});
|
||||
|
||||
materializePlan(plan);
|
||||
|
||||
const taskFile = fs.readFileSync(plan.workerPlans[0].taskFilePath, 'utf8');
|
||||
|
||||
assert.ok(
|
||||
taskFile.includes('Report results in your final response.'),
|
||||
'Task file should tell the worker to report in stdout'
|
||||
);
|
||||
assert.ok(
|
||||
taskFile.includes('Do not spawn subagents or external agents for this task.'),
|
||||
'Task file should keep nested workers single-session'
|
||||
);
|
||||
assert.ok(
|
||||
!taskFile.includes('Write results and handoff notes to'),
|
||||
'Task file should not require writing handoff files outside the worktree'
|
||||
);
|
||||
assert.ok(
|
||||
!taskFile.includes('Update `'),
|
||||
'Task file should not instruct the nested worker to update orchestration status files'
|
||||
);
|
||||
} finally {
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('overlaySeedPaths copies local overlays into the worker worktree', () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-orchestrator-overlay-'));
|
||||
const repoRoot = path.join(tempRoot, 'repo');
|
||||
const worktreePath = path.join(tempRoot, 'worktree');
|
||||
|
||||
try {
|
||||
fs.mkdirSync(path.join(repoRoot, 'scripts'), { recursive: true });
|
||||
fs.mkdirSync(path.join(repoRoot, '.claude', 'plan'), { recursive: true });
|
||||
fs.mkdirSync(path.join(worktreePath, 'scripts'), { recursive: true });
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(repoRoot, 'scripts', 'orchestrate-worktrees.js'),
|
||||
'local-version\n',
|
||||
'utf8'
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(repoRoot, '.claude', 'plan', 'workflow-e2e-test.json'),
|
||||
'{"seeded":true}\n',
|
||||
'utf8'
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(worktreePath, 'scripts', 'orchestrate-worktrees.js'),
|
||||
'head-version\n',
|
||||
'utf8'
|
||||
);
|
||||
|
||||
overlaySeedPaths({
|
||||
repoRoot,
|
||||
seedPaths: [
|
||||
'scripts/orchestrate-worktrees.js',
|
||||
'.claude/plan/workflow-e2e-test.json'
|
||||
],
|
||||
worktreePath
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
fs.readFileSync(path.join(worktreePath, 'scripts', 'orchestrate-worktrees.js'), 'utf8'),
|
||||
'local-version\n'
|
||||
);
|
||||
assert.strictEqual(
|
||||
fs.readFileSync(path.join(worktreePath, '.claude', 'plan', 'workflow-e2e-test.json'), 'utf8'),
|
||||
'{"seeded":true}\n'
|
||||
);
|
||||
} finally {
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`\n=== Results: ${passed} passed, ${failed} failed ===`);
|
||||
if (failed > 0) process.exit(1);
|
||||
Reference in New Issue
Block a user