Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/api-quota.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ Captions are the other pricey read: `videos transcript` first lists the tracks
Author metadata per video rather than pulling transcripts across a whole
channel.

Comment moderation is the other cost to plan for. `comments.setModerationStatus`
costs 50 units per call, and `commentThreads.list` costs 1 unit per page of up to
100 comments. One call can change up to 50 comment ids, and `comments reject` and
`comments publish` send them in batches of 50. A run of 200 ids is 4 calls (200
units). One call per id is 200 calls (10 000 units), which is the full daily
budget. Always pass all ids to one command.

`comments list --unanswered` reads the `replies` part with the thread. That part
holds only a few replies. For a thread with more replies, the CLI makes one
more `comments.list` call (1 unit per page) to check for a reply from the owner.

## Increasing the quota

In the Google Cloud Console, go to **IAM & Admin** :material-arrow-right:
Expand Down
124 changes: 102 additions & 22 deletions docs/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,129 @@ downstream tooling.
ytstudio comments list --video <video-id>
ytstudio comments list --video <video-id> -o json | jq

# Held queue, ordered chronologically
# Held queue for one video, newest first
ytstudio comments list --video <video-id> --status held --sort time

# Whole held queue of the channel
ytstudio comments list --status held -n 500 -o json
```

`--status` accepts `published`, `held`, or `spam` (mapped internally to
YouTube's `published`, `heldForReview`, and `likelySpam` values). `--sort`
accepts `time` or `relevance`; the YouTube API only honours `relevance` for
a single video, so `--sort relevance` requires `--video <id>`. Omit
`--video` to list across the channel (time-sorted only).
YouTube's `published`, `heldForReview`, and `likelySpam` values). It works
with and without `--video`. `--sort` accepts `time` or `relevance`. The
YouTube API uses `relevance` only for a single video, so
`--sort relevance` requires `--video <id>`. Omit `--video` to list across
the channel (time-sorted only).

`--limit/-n` is the number of comments to return. The CLI reads as many
pages of 100 as it needs (1 quota unit per page).

## Approve held comments
### Unanswered comments

```bash
ytstudio comments publish <comment-id> [<comment-id> ...]
ytstudio comments list --unanswered -n 50 -o json
```

`publish` takes one or more comment IDs and transitions each to
`published`.
`--unanswered` returns only threads that have no reply from the channel
owner. It skips threads that the owner started. It works only with published
comments.

### Signals in JSON output

`-o json` adds fields that the CLI calculates without a model. They are
evidence for the reader, not a decision:

| Field | Meaning |
|---|---|
| `author_channel_id` | Channel id of the author. Use it to find repeat authors. |
| `reply_count` | Number of replies in the thread. |
| `has_link` | The text contains a link (`https://`, `www.`, or `host/path` such as `t.me/x`). |
| `link_hosts` | The hosts of those links. |
| `off_youtube_link` | At least one link goes to a host that is not YouTube. |
| `duplicate_of` | Id of an earlier comment with the same text on another video or from the same author. The CLI ignores case, punctuation and spacing. It does not compare texts shorter than 15 characters. |
| `impersonation_suspect` | The display name is close to the channel title or handle, and the author is not the channel owner. |

## Reject
The CLI looks for duplicates only in the comments of one command run. Raise
`-n` to compare more of the backlog.

## Approve and reject

```bash
ytstudio comments reject <comment-id> [<comment-id> ...]
ytstudio comments reject <comment-id> --ban # also ban the author
ytstudio comments publish <comment-id> [<comment-id> ...] # preview
ytstudio comments publish <comment-id> [<comment-id> ...] --execute # apply

ytstudio comments reject <comment-id> [<comment-id> ...] # preview
ytstudio comments reject <comment-id> [<comment-id> ...] --execute # apply
ytstudio comments reject <comment-id> --ban --execute # also ban the author
```

`reject` hides the comment from public view. Pass `--ban` to also ban the
author from the channel.
Both commands do a **dry run by default**. The preview shows the author, the
text, the video and the signals of each comment. It changes nothing. Add
`--execute` to apply. `--ban` also needs `--execute`.

The preview reads the comments from the API, not from your input. It searches
for each id in this order:

1. By thread id.
2. By comment id.
3. In the held and spam queues.
4. In the local moderation log.

If the CLI cannot find an id, the command lists it, changes nothing and exits
with code 1.

### Moderation log

`--execute` appends to `profiles/<name>/moderation-log.jsonl` **before** each
API call. Each line has the comment id, author, author channel id, text, video
id, a timestamp and the action. After the call the CLI appends an `applied` or
`failed` line for each id.

This log is the only record of a rejected comment. The API cannot list
rejected comments, and a reject also hides all replies of the comment. To undo
a reject, run `comments publish <ids>` with the ids from the log. The preview
then shows the text from the log. The YouTube documentation does not say if
YouTube accepts a publish on a rejected comment.

### Batches and partial failure

The CLI sends up to 50 ids per API call. If a call fails, the CLI stops and
exits with code 1. It prints the ids in three groups:

- Applied: the API accepted the call.
- Status unknown: the call failed with a 5xx error, a timeout or a network
error. The change can be applied or not. Check these comments in YouTube
Studio before you run the command again.
- Not applied: the CLI did not send these ids, or the API refused the call
with a 4xx error. Run the command again with these ids.

The log marks each id as `applied`, `unknown` or `failed`.

## Reply

```bash
ytstudio comments reply <comment-id> --text "Thanks for watching!"
ytstudio comments reply <comment-id> --text "Thanks for watching!" # preview
ytstudio comments reply <comment-id> --text "Thanks for watching!" --execute # post
```

`reply` posts a public reply to a comment and prints the new reply id.
Replies are flat on YouTube: `<comment-id>` must be a **top-level** comment
id (the `id` shown by `comments list`), not the id of another reply. Passing
a reply id (or an otherwise invalid id) returns a clear error. Like
`publish` and `reject`, `reply` executes immediately.
`reply` does a dry run by default. The preview shows the comment and the
reply text. With `--execute`, it posts the reply and prints the new reply id. Replies are flat
on YouTube: `<comment-id>` must be a **top-level** comment id (the `id` shown
by `comments list`), not the id of another reply. Passing a reply id (or an
otherwise invalid id) returns a clear error.

## Triage with an agent

The agent makes the decisions. The CLI supplies the context, a preview and a
log for each write. Store the channel's rules once with `ytstudio profile policy edit` (see
[Profiles](profiles.md#moderation-policy)). The loop and the label set are in
the bundled agent skill (`skills/ytstudio/SKILL.md`).

!!! note "Quota"

`comments.setModerationStatus` and `comments.insert` (reply) each cost
about 50 quota units per call. For larger moderation runs, see
[API quota](api-quota.md).
about 50 quota units per call. A preview costs about 1 unit per 50 ids.
If an id lookup does not find a comment, the preview also reads the
held and spam queues. That fallback costs 1 unit per page of 100
comments.
For larger moderation runs, see [API quota](api-quota.md).
21 changes: 20 additions & 1 deletion docs/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ The file lives at `profiles/<name>/brand.md` and is written owner-only
(`0600`), the same as credentials, because a brand voice can encode private
channel strategy.

## Moderation policy

Each profile can also carry a **moderation policy**: a markdown file that says
how an agent must triage comments on the channel. Write down what to reject,
what to leave held, what never to touch, and which topics always go to you.
The agent reads it before [comment triage](comments.md#triage-with-an-agent).

```bash
ytstudio profile policy show # print the active profile's policy
ytstudio profile policy edit # create/open moderation.md in $EDITOR
ytstudio profile policy set --file policy.md # import a policy file
```

The commands work the same as the `brand` commands. The file lives at
`profiles/<name>/moderation.md` (`0600`). `moderation.md` controls what happens
to a comment. `brand.md` controls how a reply sounds. Keep them separate.

## Storage

```
Expand All @@ -61,7 +78,9 @@ channel strategy.
└── work/
├── credentials.json
├── meta.json
└── brand.md # optional; per-channel brand voice (0600)
├── brand.md # optional, per-channel brand voice (0600)
├── moderation.md # optional, comment moderation policy (0600)
└── moderation-log.jsonl # written by comments reject/publish --execute (0600)
```

Profile directories are `0700`; credential files are `0600`. State writes go
Expand Down
127 changes: 109 additions & 18 deletions skills/ytstudio/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ mistakes:
also support `-o csv`. The auth/setup commands (`init`, `login`, `status`)
have no JSON mode.
2. **Most mutations are dry-run by default.** Commands with `--execute`
(`videos update/search-replace/upload`, `livestreams schedule/update`, and
playlist writes) preview what they *would* do and change nothing until you
re-run the exact command with `--execute`. Always preview first, show the
(`videos update/search-replace/upload`, `livestreams schedule/update`,
`comments publish/reject/reply`, and playlist writes) preview what they
*would* do. They change nothing until you re-run the exact command with
`--execute`. Always preview first, show the
user the preview when consequential, then re-run with `--execute`.

Some writes execute immediately because they have no `--execute`: comment
moderation/replies (`comments publish`, `comments reject`, `comments reply`) and
livestream transitions (`livestreams start`, `livestreams stop`). Treat these as
high-risk: confirm intent before running them.
Livestream transitions (`livestreams start`, `livestreams stop`) have no
`--execute`, so they execute immediately. Treat them as high-risk. Confirm the
intent of the user before you run them.

Up to 0.4.x, `comments publish`, `comments reject` and `comments reply`
executed immediately. Now they show a preview by default and need `--execute`.

Treat write operations as costly and irreversible-ish: they consume API quota
(see [Quota](#quota-awareness)) and act on a real, public channel.
Expand Down Expand Up @@ -302,19 +305,106 @@ ytstudio comments list -o json # recent comments across t
ytstudio comments list --status held -o json # the moderation queue
ytstudio comments list --status spam -o json # likely spam comments
ytstudio comments list --sort time -o json # channel-wide newest first
ytstudio comments list -v <video-id> --status held -o json # held queue of one video
ytstudio comments list -v <video-id> --sort relevance -n 50 -o json
ytstudio comments publish <comment-id> [<comment-id> ...] # approve held; executes immediately
ytstudio comments reject <comment-id> --ban # reject (+ optional ban); executes immediately
ytstudio comments reply <comment-id> -t "Thanks!" # executes immediately
ytstudio comments list --unanswered -n 50 -o json # no reply from the owner yet
ytstudio comments publish <comment-id> [<comment-id> ...] # preview
ytstudio comments publish <comment-id> [<comment-id> ...] --execute # approve held
ytstudio comments reject <comment-id> [<comment-id> ...] --execute # reject
ytstudio comments reply <comment-id> -t "Thanks!" # preview
ytstudio comments reply <comment-id> -t "Thanks!" --execute # post
```

`comments list` without `-v/--video` is channel-wide. Use `--status spam` for
spam review. Channel-wide listing supports `--sort time`; `--sort relevance`
requires `-v/--video` because of a YouTube API limitation. `publish`/`reject`
take one or more comment ids and execute immediately (no `--execute` dry-run).
`reply` also posts immediately. Confirm the exact comment ids/text first.
`--ban` on `reject` also bans the author - only use it when the user explicitly
asks to ban.
`comments list` without `-v/--video` is channel-wide. `--status` works with and
without `-v`. Channel-wide listing supports `--sort time`. `--sort relevance`
requires `-v/--video` because of a YouTube API limitation. `-n` follows pages, so
`-n 500` returns up to 500 comments.

`-o json` adds these signals for each comment. They are evidence, not decisions.

- `author_channel_id`
- `reply_count`
- `has_link`
- `link_hosts`
- `off_youtube_link`: a link to a host that is not YouTube.
- `duplicate_of`: the id of an earlier copy of the same text, on another video
or from the same author.
- `impersonation_suspect`: the name is close to the channel title or handle,
and the comment comes from another channel.

`publish`/`reject` take one or more ids. The preview shows the author, text,
video and signals from the API. If the CLI cannot find an id, the command stops
and changes nothing. `--execute` writes each comment to
`profiles/<name>/moderation-log.jsonl` before the API call. If a batch fails, the
command stops and exits with code 1. It prints three groups: applied, status
unknown (5xx, timeout or network error), and not applied. Tell the user to check
the "status unknown" ids in YouTube Studio. Do not send them again without a check.
`--ban` on `reject` also bans the author. Never pass `--ban` unless the user
explicitly asks to ban.

#### Comment triage - policy-grounded, preview first

You make the decisions. The CLI gives you the policy, the comments, the
signals, and a preview and a log for each write. Do these steps:

1. Run `ytstudio profile policy show` to get the moderation rules of the
channel. If there is no policy, tell the user. Ask the user to write one
with `ytstudio profile policy edit`. Do not moderate without a policy.
2. Run `ytstudio comments list --status held -n 500 -o json`. For one video,
add `-v <id>`. For the likely-spam queue, use `--status spam`.
3. Give each comment one label from the table below. Use the policy to select
the label.
4. Run `ytstudio comments reject <ids>` without `--execute`. **Show the preview
to the user.** Group the comments by label and give the reason for each
comment.
5. After the user confirms, run the same command with `--execute`. Use the same
steps for `comments publish <ids>`.
6. Tell the user which comments you left held, and why. Include questions,
leads, and all comments that you were not sure about.

| Label | Meaning | Default action |
|---|---|---|
| `junk` | link farms, fake giveaways, phishing, crypto/WhatsApp/Telegram bait | propose reject |
| `impersonation` | author name copies the channel, "message me on Telegram" | propose reject, tell the user |
| `toxic` | harassment, slurs, threats | propose reject |
| `question` | a question to the creator | leave held, show to the user, candidate for a reply |
| `lead` | buying intent, price or availability questions, collaboration requests | leave held, show to the user, never act on it |
| `criticism` | negative but genuine | publish, never reject |
| `praise` / `neutral` | positive or plain | publish |

Use the label `junk`, not `spam`. `--status spam` is the classification of
YouTube. The label is your decision. If you are not sure about the label of a
comment, leave the comment held. Put it in the "needs you" list.

Hard rules:

- Never ban.
- When in doubt, leave the comment held.
- Never reject genuine criticism or negative feedback.
- Never reject a comment only because it is negative about the channel.
- For each reject that you propose, give the line in the policy or the signal
that is the reason.

**Pass all ids to one command.** `comments.setModerationStatus` costs 50 units
per call. The CLI sends 50 ids per call. A loop with one command per id costs
50 units per comment. After 200 comments, that loop uses the full 10,000-unit
daily budget.

Undo: the API cannot list rejected comments. To restore a rejected comment:

1. Read its id from `moderation-log.jsonl`.
2. Run `comments publish <id>` (preview, then `--execute`).

The YouTube documentation does not say if YouTube accepts this. Report the
result to the user.

Reply triage is a separate pass on published comments:

1. Run `ytstudio comments list --unanswered -o json`.
2. Write draft replies in the brand voice (`profile brand show`).
3. Preview each reply with `comments reply <id> -t "..."`.
4. Show the previews to the user.
5. Post each reply with `--execute`.

### livestreams - broadcast lifecycle

Expand Down Expand Up @@ -360,7 +450,8 @@ resetting at midnight Pacific. Rough costs:
| Read (list/show videos, comments, playlists; analytics) | ~1 unit |
| Caption list (`videos captions`) | ~50 units |
| Caption download (`videos transcript`) | ~200 units |
| Write (update video, moderate comment, playlist insert/reorder, schedule broadcast) | ~50 units |
| Write (update video, playlist insert/reorder, schedule broadcast, reply) | ~50 units |
| Comment moderation (`comments publish/reject`) | ~50 units per call of up to 50 ids |
| Search (`playlists add --from-search`) | ~100 units/call |
| Upload (`videos upload`) | ~1600 units |

Expand Down
Loading