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

# Social repurpose

> T1 starter · marketing: one post becomes a thread, a LinkedIn post and a newsletter blurb, in parallel.

> **T1 starter · marketing / creators**: the diamond DAG. One read fans
> into three rewrites that run **concurrently**, and a single write
> merges the bundle. The craft lives in the prompts; the engine handles
> the choreography.

## The job

You wrote the post. Now it needs to be a thread, a LinkedIn version and
a newsletter blurb: same ideas, three voices. Sequential chatbot
sessions drift; this file keeps one source and rewrites it three ways at
once.

## The shape

```mermaid theme={"system"}
flowchart LR
  post["post · nika:read"]:::invoke
  thread["thread"]:::infer
  linkedin["linkedin"]:::infer
  newsletter["newsletter"]:::infer
  bundle["bundle · nika:write"]:::invoke
  post --> thread
  post --> linkedin
  post --> newsletter
  thread --> bundle
  linkedin --> bundle
  newsletter --> bundle
  classDef infer fill:#5b8cff22,stroke:#5b8cff,color:#5b8cff
  classDef invoke fill:#22d3ee22,stroke:#22d3ee,color:#22d3ee
```

## The file

```yaml social-repurpose.nika theme={"system"}
nika: social-repurpose

model: ollama/qwen3.5:4b   # local · zero key · swap for mistral/mistral-large-latest or any provider

const:
  # The sample post ships with the repo. Point this at your own and move the
  # read permit with it — `permits:` cannot interpolate (NIKA-AUTH-007).
  post_path: "examples/fixtures/launch-post.md"
permits:
  tools: ["nika:read", "nika:write"]
  # One file in, one file out · each named exactly, no subtree granted.
  fs:
    read: ["examples/fixtures/launch-post.md"]
    write: ["out/social-bundle.md"]

tasks:
  post:
    invoke:
      tool: "nika:read"
      args: { path: "${{ const.post_path }}" }

  # Three rewrites · no deps between them · they run concurrently.
  thread:
    with:
      post: ${{ tasks.post.output }}
    infer:
      # a reasoning model needs 16384 here, or a documented run.reasoning.effort: low
      max_tokens: 700
      prompt: "Turn this post into a 6-tweet thread · keep the voice · ${{ with.post }}"

  linkedin:
    with:
      post: ${{ tasks.post.output }}
    infer:
      # a reasoning model needs 16384 here, or a documented run.reasoning.effort: low
      max_tokens: 500
      prompt: "Rewrite this post for LinkedIn · hook first · ${{ with.post }}"

  newsletter:
    with:
      post: ${{ tasks.post.output }}
    infer:
      # a reasoning model needs 16384 here, or a documented run.reasoning.effort: low
      max_tokens: 200
      prompt: "Write a 3-sentence newsletter blurb for this post · ${{ with.post }}"

  bundle:
    with:
      t: ${{ tasks.thread.output }}
      l: ${{ tasks.linkedin.output }}
      n: ${{ tasks.newsletter.output }}
    invoke:
      tool: "nika:write"
      args:
        path: out/social-bundle.md
        create_dirs: true
        # Prose artifact → a `content: |` block with interpolations is right
        # here. A `.json` artifact is the opposite case: one `${{ … }}` value,
        # never hand-typed braces (that emits unquoted fields).
        content: |
          # Social bundle

          ## Thread
          ${{ with.t }}

          ## LinkedIn
          ${{ with.l }}

          ## Newsletter
          ${{ with.n }}

outputs:
  bundle_path: ${{ tasks.bundle.output }}
```

## How it works

**1. Fan-out by omission**

`thread`, `linkedin` and `newsletter` each depend only on `post`:
no deps between them, so the engine runs all three at the same time.

**2. with: keeps the merge readable**

`bundle` binds the three outputs to one-letter names in `with:`, the
boundary every task reference crosses: a `${{ tasks.… }}` written
straight into `args:` is refused (`NIKA-VAR-021`). Short names keep a
template that interpolates three outputs readable.

**3. One multi-line write**

The `content:` is a YAML block scalar with three interpolations:
the bundle file is assembled by the engine, no model needed for glue.

## Constructs you just used

| Construct | Where | Reference |
| - | - | - |
| diamond fan-out / fan-in | the whole DAG | [Workflows](https://docs.nika.sh/concepts/workflows.md) |
| `with:` aliasing | `bundle` | [Bindings](https://docs.nika.sh/concepts/bindings.md) |
| block-scalar `content:` | `bundle.args` | [YAML syntax](https://docs.nika.sh/reference/yaml-syntax.md) |

## Run it

> [!NOTE]
>
> **What it needs:** A local model ([Ollama](https://ollama.com) serving `qwen3.5:4b`) and the sample launch post.

**1. Rehearse it**

```bash theme={"system"}
nika try social-repurpose
```

A mock model answers, the sample files come with it, and nothing is written in your folder.

**2. Get your own copy**

Save the file above as `social-repurpose.nika` in a new folder, then download the sample it reads:

```bash theme={"system"}
FIXTURES=https://raw.githubusercontent.com/supernovae-st/nika/v0.124.3/crates/nika-pack/pack/examples/fixtures
mkdir -p examples/fixtures
curl -fsSLo examples/fixtures/launch-post.md "$FIXTURES/launch-post.md"
```

**3. Check it, then run it**

```bash theme={"system"}
nika check social-repurpose.nika
nika run social-repurpose.nika --model mock/echo   # a mock model, no key
ollama pull qwen3.5:4b   # once, for the real run
nika run social-repurpose.nika
```

The run writes `out/social-bundle.md`.

Any other model works: pass `--model <provider>/<name>` with its key, and cap a cloud model with `--max-cost-usd`.

## Make it yours

* Add a fourth branch (YouTube description, Mastodon, press blurb): it's three lines and it runs in the same wave.
* Pin a glossary: put your brand terms in a `const:` entry and interpolate it into each prompt.
* Want every language too? Chain this into [Localization factory](https://docs.nika.sh/examples/localization-factory.md).

> [card] [Level up · T2 chains](https://docs.nika.sh/examples/release-notes.md)
>
> Next tier: typed outputs, in-place file edits and a webhook ping.
> Release day, automated.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.