Skip to content

How to use output styles with the sdk? #211

@brickfrog

Description

@brickfrog

As far as I can tell output styles work in --print mode but not in --output-format stream-json mode, which is what the agent-sdk uses. Is there something I'm missing? I wanted to have an application mode switch output styles based on use-case, but seems like it doesn't honor them at all.

  # Create output style
  cat > ~/.claude/output-styles/test.md << 'EOF'
  ---
  name: test
  description: lowercase only
  ---

  use lowercase exclusively. respond with extreme brevity.

  examples:
  - instead of "Hello! How can I help?" → "hey"
  - instead of verbose explanations → concise answers
  EOF

  # Create settings file
  echo '{"outputStyle": "test"}' > /tmp/settings.json

  # Test - output style is ignored
  printf '{"type":"message","role":"user","content":[{"type":"text","text":"hello"}]}\n' | \
    claude --output-format stream-json --verbose \
    --append-system-prompt "You are helpful." \
    --settings /tmp/settings.json \
    --input-format stream-json

  Expected: Lowercase response like "hey" or "yo"
  Actual: Normal case response like "Hello! How can I help you today?"

The init message shows "output_style":"test" confirming it's loaded, but the actual responses don't follow the output style instructions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions