AI agent guide

Instructions for Claude Code, Codex, Cursor or any agent to use SoluCortex autonomously.

Initial setup

The agent reads credentials from ai/.env.ai (never hardcoded):

bash
SOLUCORTEX_URL=https://solucortex.ai
SOLUCORTEX_PROJECT_ID=<project-uuid>
SOLUCORTEX_API_KEY=scx_<api-key>
🔒 ai/.env.ai must be in .gitignore. The agent must never hardcode or commit these variables.

Session startup flow

At the start of each work session, the agent always loads the relevant context for the task:

bash
source ai/.env.ai

CONTEXT=$(curl -s -X POST "$SOLUCORTEX_URL/api/v1/context/build" \
  -H "Authorization: Bearer $SOLUCORTEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"project_id\": \"$SOLUCORTEX_PROJECT_ID\",
    \"query\": \"$DESCRIBED_TASK\"
  }" | python3 -c "import sys,json; print(json.load(sys.stdin).get('context_text',''))")

echo "$CONTEXT"

When to register memories

The agent registers memories autonomously - without waiting for user instruction - when:

  • It makes a technical decision that was not documented.
  • It detects a new risk or technical debt.
  • It closes an important task.
  • It discovers a non-obvious behavior of the system (bug, workaround, constraint).
bash
source ai/.env.ai

curl -s -X POST "$SOLUCORTEX_URL/api/v1/memories" \
  -H "Authorization: Bearer $SOLUCORTEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"project_id\": \"$SOLUCORTEX_PROJECT_ID\",
    \"type\": \"decision\",
    \"title\": \"Short title for the decision\",
    \"content\": \"Full description of why this decision was made, discarded alternatives and context.\",
    \"importance\": 8
  }"

Memory types

Valid values for the type field:

ValueDescription
architectureTech stack, project structure
decisionImportant technical decisions already made
riskIdentified, resolved or pending risk
conventionTeam rule, standard or convention
bug_historyBug resolved with a lesson for the future
tech_debtTechnical debt, legacy code or pending improvement
sensitive_moduleDelicate module that should not be touched lightly
learningGeneral project learning
external_integrationExternal service, API or dependency integration

importance field

Integer between 1 and 10. Controls priority in the context/build results.

RangeRecommended use
9–10Critical - system constraints, immutable decisions
7–8Important - relevant technical decisions, key component state
5–6Normal - conventions, general state
1–4Low - background context, historical notes

Critical rules

Never run without explicit user confirmation:
Destructive commands on the database: resets, drops, truncates or deletes without conditions.
🔒
Never:
• Hardcode API keys, tokens or URLs in code or config files.
• Commit files with secrets or credentials.

Rate limits

Limits are applied per API key. If the agent receives a 429, it should wait and retry with exponential backoff.

EndpointsLimit
Memories, snapshots, search, context120 req/min
context/build and search/semantic20 req/min

Quick endpoint reference

ActionEndpoint
Load contextPOST /api/v1/context/build
Register memoryPOST /api/v1/memories
Search memoriesPOST /api/v1/search/semantic
List memoriesGET /api/v1/memories?project_id=...&per_page=50&page=1
Update memoryPATCH /api/v1/memories/{id}
Create snapshotPOST /api/v1/snapshots

Final validation

Before closing a task, run the minimum validation that proves the public surface still works:

  1. php artisan config:clear
  2. php artisan test
  3. ./vendor/bin/pint --test if Pint is configured in the project