docs/sgai-skills/using-sgai/SKILL.md
Drive sgai (Software Garden AI) from any MCP-capable harness or AI agent. Covers the cyclical probe/poll/act workflow for managing AI software factory workspaces, sessions, and human interaction. Use this as the entrypoint when orchestrating sgai from Claude Code, Codex, or any AI harness.
npx skillsauth add sandgardenhq/sgai using-sgaiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
sgai is a software factory system that runs AI agents in workspaces. This skill teaches you to drive it via the HTTP API or MCP tools.
All examples assume BASE_URL=http://127.0.0.1:PORT where PORT is shown in the server startup log:
sgai serve listening on http://127.0.0.1:PORT
The MCP endpoint is at /mcp/external on the same server (e.g. http://127.0.0.1:PORT/mcp/external).
The core pattern for driving sgai is a continuous loop:
LOOP:
1. PROBE → GET /api/v1/state # Discover all workspaces + status
2. CHECK → pendingQuestion != null? # Does any workspace need human input?
3. ACT → based on workspace status # Start, steer, respond, or wait
4. WAIT → poll again after delay # Repeat
curl -s $BASE_URL/api/v1/state
Response shape:
{
"workspaces": [
{
"name": "my-project",
"running": false,
"needsInput": false,
"inProgress": false,
"status": "agent-done",
"currentAgent": "coordinator",
"task": "Planning implementation",
"pendingQuestion": null
}
]
}
Key fields to check per workspace:
running — is a session active?needsInput — does the agent need a human response?pendingQuestion — non-null when human input is requiredstatus — current workflow status stringinProgress — is work actively happening?When workspace.pendingQuestion != null, the agent is blocked waiting for human input.
{
"pendingQuestion": {
"questionId": "abc123def456",
"type": "free-text",
"agentName": "coordinator",
"message": "Which approach should we take?",
"questions": []
}
}
Question types:
"free-text" — respond with a text answer"multi-choice" — select from provided choices"work-gate" — approve to proceed (select approval text)| Workspace State | Action |
|----------------|--------|
| needsInput: true | Call respond endpoint with answer |
| running: false and has goal | Start session |
| running: true | Monitor / optionally steer |
| Session complete | Check results, start next task |
# Free-text response
curl -s -X POST $BASE_URL/api/v1/workspaces/{name}/respond \
-H "Content-Type: application/json" \
-d '{"questionId": "abc123def456", "answer": "Use the microservice approach"}'
# Multi-choice response
curl -s -X POST $BASE_URL/api/v1/workspaces/{name}/respond \
-H "Content-Type: application/json" \
-d '{"questionId": "abc123def456", "selectedChoices": ["Option A"]}'
For detailed documentation on specific operations:
If using the MCP interface instead of HTTP, all tools are available at /mcp/external:
# List all 38 tools
npx mcporter list --http-url http://HOST:PORT/mcp/external --allow-http
Key MCP tools mirror the HTTP API:
list_workspaces → GET /api/v1/statestart_session → POST /api/v1/workspaces/{name}/startrespond_to_question → POST /api/v1/workspaces/{name}/respondwait_for_question → polls + elicitation (MCP only)Subscribe to state changes instead of polling:
curl -s -N $BASE_URL/api/v1/signal
# Emits: event: reload\ndata: {}\n\n
When you receive a reload event, re-fetch /api/v1/state.
# 1. Create workspace
curl -X POST $BASE_URL/api/v1/workspaces \
-d '{"name": "my-project"}'
# 2. Write a GOAL.md
curl -X PUT $BASE_URL/api/v1/workspaces/my-project/goal \
-d '{"content": "# My Goal\n- [ ] Build the feature"}'
# 3. Start session in auto (self-drive) mode
curl -X POST $BASE_URL/api/v1/workspaces/my-project/start \
-d '{"auto": true}'
# 4. Poll for completion
while true; do
STATE=$(curl -s $BASE_URL/api/v1/state)
NEEDS_INPUT=$(echo $STATE | jq '.workspaces[0].needsInput')
if [ "$NEEDS_INPUT" = "true" ]; then
# Handle question...
fi
sleep 5
done
documentation
Start, stop, and steer agentic sessions in sgai workspaces. Use when you need to launch AI agent sessions, halt running sessions, or inject steering instructions to guide the agent mid-execution without stopping it.
development
Monitor sgai workspace status, events, progress, diffs, and workflow diagrams. Use when you need to observe what agents are doing, track progress, get the current state of all workspaces, subscribe to real-time updates via SSE, or inspect code changes.
development
Access agents, skills, and code snippets available in sgai workspaces. Use when you need to discover what agents are defined in a workspace, browse available skills, get skill instructions, find code snippets by language, or retrieve snippet content for a specific task.
data-ai
Handle agent questions and work gates in sgai workspaces. Use when an agent is blocked waiting for human input, when you need to respond to multi-choice questions, approve work gates, or provide free-text answers to agent queries.