> ## Documentation Index
> Fetch the complete documentation index at: https://docs.decimal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Reconcile a batch of local skills with the platform

> One endpoint, two consumers:

- **SDK auto-discovery** (CI, agent boot): defaults are right.
  Send `{"skills": [...]}` and read `created` / `updated` / `unchanged` counts.
- **Interactive CLI** (`decimalai skills sync ./skills/`): pass
  `response_mode="diff"` to get a per-skill `actions` array including
  `body_markdown` for any skill where the remote version is newer
  (so the CLI can overwrite local files).

Conflict policy: with `conflict_policy="newer_wins"` (default), the
side whose timestamp is later wins — best for human-in-the-loop CLI.
For CI/SDK pipelines where the repo is the source of truth, pass
`conflict_policy="local_wins"` to force every push. `remote_wins` is
the inverse — useful for "treat the platform as canonical."

Empty bodies are 422'd at Pydantic validation. Invalid names are
409'd at the same layer. Per-skill issues that survive validation
(e.g. a transient DB error) land in the `failures` array; the rest
of the batch still processes.

`content_hash` on each entry is optional — clients that already
computed SHA-256 (CLI walking a directory) can pass it to save a
server-side hash; clients that didn't (SDK auto-discovery) can omit.



## OpenAPI

````yaml /openapi.json post /api/v1/skills/sync
openapi: 3.1.0
info:
  title: DecimalAI Platform
  description: Agent Dataset Lifecycle Platform — Backend API
  version: 0.1.0
servers: []
security:
  - BearerAuth: []
tags:
  - name: traces
    description: >-
      Ingest, search, and inspect agent execution traces. A trace is the atomic
      unit of the platform — every other feature (evaluation, compatibility
      scoring, dataset building) operates on traces. Each trace is auto-tagged
      with the manifest hash of the agent that produced it.
  - name: eval-scores
    description: >-
      Push, fetch, and aggregate per-trace evaluation scores. Scores carry
      source provenance (built-in, DeepEval, LangSmith, custom) and feed the
      unified decision engine, which produces a keep / repair / replay / drop
      verdict per trace.
  - name: skills
    description: >-
      Manage reusable instruction blocks (SKILL.md files) that modify agent
      behavior. Skills are first-class manifest components — changes to a skill
      appear in your regression-check impact reports. Use these endpoints to
      create, version, fork, and sync skills with your local SKILL.md files.
  - name: manifests
    description: >-
      Register and inspect manifest versions. A manifest is a snapshot of your
      agent's structural identity (tools, prompts, models, skills) at a point in
      time. The SDK registers manifests automatically; these endpoints expose
      the underlying records.
  - name: datasets
    description: >-
      Build versioned SFT/DPO training datasets from manifest-classified,
      eval-scored traces. Datasets are reproducible — each version locks the
      manifest and filter set used to build it. Export as JSONL, Parquet, or
      push to HuggingFace Hub.
  - name: replay
    description: >-
      Re-execute historical traces against a new manifest version. Replay is the
      deferred-future capability for behavioral verification of agent changes.
      The SDK creates a replay batch, your worker executes each task, then
      submits results back here for eval scoring.
  - name: registry
    description: >-
      Browse and install community skills from the public skills registry. Each
      registry skill carries a SkillScore — an evidence-tiered quality composite
      computed from real-world evals, benchmarks, and ratings across
      organizations. Installing creates a fork in your org — edits don't affect
      the public version.
  - name: agents
    description: >-
      List and inspect agents, plus their multi-agent topology (orchestrator →
      sub-agent edges discovered from traces). Agents are identified by a stable
      agent_name string set in your SDK init() call.
  - name: import
    description: >-
      Bulk-import historical traces from another observability platform or a
      JSONL backup. Useful for migrating from LangSmith / Braintrust / Langfuse.
      Duplicate trace IDs are silently skipped — re-running an import is safe.
paths:
  /api/v1/skills/sync:
    post:
      tags:
        - skills
      summary: Reconcile a batch of local skills with the platform
      description: |-
        One endpoint, two consumers:

        - **SDK auto-discovery** (CI, agent boot): defaults are right.
          Send `{"skills": [...]}` and read `created` / `updated` / `unchanged` counts.
        - **Interactive CLI** (`decimalai skills sync ./skills/`): pass
          `response_mode="diff"` to get a per-skill `actions` array including
          `body_markdown` for any skill where the remote version is newer
          (so the CLI can overwrite local files).

        Conflict policy: with `conflict_policy="newer_wins"` (default), the
        side whose timestamp is later wins — best for human-in-the-loop CLI.
        For CI/SDK pipelines where the repo is the source of truth, pass
        `conflict_policy="local_wins"` to force every push. `remote_wins` is
        the inverse — useful for "treat the platform as canonical."

        Empty bodies are 422'd at Pydantic validation. Invalid names are
        409'd at the same layer. Per-skill issues that survive validation
        (e.g. a transient DB error) land in the `failures` array; the rest
        of the batch still processes.

        `content_hash` on each entry is optional — clients that already
        computed SHA-256 (CLI walking a directory) can pass it to save a
        server-side hash; clients that didn't (SDK auto-discovery) can omit.
      operationId: sync_skills_api_v1_skills_sync_post
      parameters:
        - name: Authorization
          in: header
          required: false
          schema:
            type: string
            title: Authorization
        - name: X-Workspace-Id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Workspace-Id
        - name: decimal_session
          in: cookie
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Decimal Session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SyncSkillsRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SyncSkillsResponse'
              example:
                status: ok
                created: 2
                updated: 1
                unchanged: 5
                pulled: 0
                failures: []
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: Python
          label: Python SDK
          source: |-
            from decimalai.skill_router import SkillRouter
            from decimalai.skills import discover_skills

            router = SkillRouter(api_key="dai_sk_...")
            local_skills = discover_skills(base_path="./skills")
            router.sync_skills(skills=local_skills)
        - lang: Bash
          label: CLI
          source: decimalai skills sync --dir ./skills
components:
  schemas:
    SyncSkillsRequest:
      properties:
        skills:
          items:
            $ref: '#/components/schemas/SyncSkillItem'
          type: array
          maxItems: 200
          minItems: 1
          title: Skills
        author:
          anyOf:
            - type: string
            - type: 'null'
          title: Author
          description: >-
            Author display name recorded on every SkillVersion created by this
            sync.
        install_id:
          anyOf:
            - type: string
              maxLength: 128
            - type: 'null'
          title: Install Id
          description: >-
            Project-local install identity (persisted by the SDK in
            .decimal/install.json). When present, the sync records per-install
            divergence state so `GET /skills/installs` can flag local/remote
            drift. Omit for back-compat: the sync then behaves exactly as
            before.
        install_label:
          anyOf:
            - type: string
              maxLength: 200
            - type: 'null'
          title: Install Label
          description: Human-friendly install label (hostname, 'ci', …) for the dashboard.
        conflict_policy:
          type: string
          enum:
            - newer_wins
            - local_wins
            - remote_wins
          title: Conflict Policy
          description: >-
            newer_wins: compare timestamps (default; right for interactive CLI).
            local_wins: always overwrite remote (right for CI / build
            artifacts). remote_wins: never overwrite local; conflicts return
            `pulled` actions.
          default: newer_wins
        response_mode:
          type: string
          enum:
            - summary
            - diff
          title: Response Mode
          description: >-
            summary: return counts only (cheap; SDK default). diff: return
            per-skill `actions` array including bodies for pulled skills (CLI).
          default: summary
      type: object
      required:
        - skills
      title: SyncSkillsRequest
      description: >-
        Validated request for POST /skills/sync.


        Single endpoint covers both CLI (bidirectional reconciliation) and SDK

        (one-way upsert) — the difference is the `response_mode` flag (rich

        `actions` array for CLI, summary counts for SDK) and the
        `conflict_policy`

        (CLI defaults to `newer_wins` for human-in-the-loop, CI/SDK should set

        `local_wins` because the repo is the source of truth).
    SyncSkillsResponse:
      properties:
        status:
          type: string
          const: ok
          title: Status
        created:
          type: integer
          title: Created
          description: Number of new skills created.
        updated:
          type: integer
          title: Updated
          description: Number of existing skills with a new version (pushed).
        unchanged:
          type: integer
          title: Unchanged
          description: Number of skills whose body hash matched — no-op.
        pulled:
          type: integer
          title: Pulled
          description: >-
            Number of skills where remote was newer; caller should refresh
            local.
          default: 0
        failures:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Failures
          description: Per-skill failures with name + error.
        actions:
          anyOf:
            - items:
                $ref: '#/components/schemas/SyncSkillAction'
              type: array
            - type: 'null'
          title: Actions
          description: Per-skill action list — present only when `response_mode='diff'`.
      type: object
      required:
        - status
        - created
        - updated
        - unchanged
      title: SyncSkillsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SyncSkillItem:
      properties:
        name:
          type: string
          maxLength: 64
          minLength: 1
          title: Name
        display_name:
          anyOf:
            - type: string
              maxLength: 200
            - type: 'null'
          title: Display Name
        description:
          type: string
          maxLength: 1024
          title: Description
          default: ''
        body_markdown:
          anyOf:
            - type: string
            - type: 'null'
          title: Body Markdown
        body:
          anyOf:
            - type: string
            - type: 'null'
          title: Body
        category:
          anyOf:
            - type: string
              maxLength: 100
            - type: 'null'
          title: Category
        trigger_phrases:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Trigger Phrases
        frontmatter:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Frontmatter
        content_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Hash
          description: Optional SHA-256 of body_markdown; computed server-side if omitted.
        local_updated_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Local Updated At
          description: ISO-8601 timestamp of the local file's last mtime (for newer_wins).
        eval_yaml_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Eval Yaml Text
          description: >-
            Optional eval.yaml co-sync — publisher's benchmark suite alongside
            SKILL.md.
        eval_yaml_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Eval Yaml Hash
          description: >-
            Optional SHA-256 of eval_yaml_text (clients may pre-compute for
            parity with content_hash).
        attachments:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Attachments
          description: >-
            Optional bundled files keyed by bundle-relative path (e.g.
            'references/icd10cm.json', 'scripts/checksum.py'); the leading
            segment must be a valid attachment directory. Mirrored into
            version-scoped SkillAttachments so the benchmark sandbox can
            materialize them — lets a publisher carry references/ over the wire
            the way the disk loader does. Text-only; capped server-side
            (count/size/path-depth).
      type: object
      required:
        - name
      title: SyncSkillItem
      description: |-
        One item in the POST /skills/sync skills array.

        Strict name validation (agentskills.io spec: a-z, digits, hyphens only,
        1-64 chars). Description and body are more lenient since the SDK
        auto-generates them. Optional `content_hash` lets clients that have
        already hashed the body (CLI walking a directory) skip the server-side
        SHA-256 — backend computes it when omitted.

        Optional `local_updated_at` feeds the `conflict_policy="newer_wins"`
        decision when remote and local diverge.
    SyncSkillAction:
      properties:
        name:
          type: string
          title: Name
        action:
          type: string
          enum:
            - created
            - pushed
            - pulled
            - no_change
            - failed
          title: Action
        new_version_number:
          anyOf:
            - type: integer
            - type: 'null'
          title: New Version Number
        new_content_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: New Content Hash
        body_markdown:
          anyOf:
            - type: string
            - type: 'null'
          title: Body Markdown
        version_number:
          anyOf:
            - type: integer
            - type: 'null'
          title: Version Number
        content_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Hash
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
      type: object
      required:
        - name
        - action
      title: SyncSkillAction
      description: |-
        One entry in the `actions` list returned in `response_mode='diff'`.

        Action values:
          - `created`: skill didn't exist on backend; freshly registered.
          - `pushed`: remote already had it; local body differed and was newer
            (or `conflict_policy='local_wins'` forced the push). Backend version
            bumped.
          - `pulled`: remote was newer (or `conflict_policy='remote_wins'`); the
            full `body_markdown` is returned so the caller can overwrite local.
          - `no_change`: content_hash matched; nothing to do.
          - `failed`: per-skill error (e.g. invalid name caught after validation).
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Enter your API key (e.g. dai_sk_test_key_001)

````