---
name: corta-spam-add-setting
description: Use when adding a new persisted user setting (a new field on SettingsRepository) in the Corta Spam app. Lists the exact fallout of files that must change — every implementer/fake breaks otherwise.
metadata:
  type: project-runbook
  version: "1.1.0"
title: corta-spam-add-setting
canonical_url: https://skilld.dev/gh/cpinan/corta-spam/corta-spam-add-setting
last_updated: 2026-10-29T10:16:35.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install cpinan/corta-spam/corta-spam-add-setting`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/corta-spam-add-setting`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/cpinan/corta-spam/corta-spam-add-setting) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/corta-spam-add-setting`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/corta-spam-add-setting --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/corta-spam-add-setting --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Add a new SettingsRepository field — Corta Spam

Adding a field to `SettingsRepository` (`shared/src/commonMain/kotlin/org/carlospinan/bloqueador/app/settings/SettingsRepository.kt`) is an interface change — every implementer must be updated in the same pass or the build breaks. This project uses hand-written fakes (no MockK), but there is now exactly one of them per repository interface, under `shared/src/commonTest/kotlin/.../testing/`.

## 1. Storage primitive (only if the value type is new)

`db/KeyValueSettingsStore.kt` currently has `readBool`/`writeBool` and `readInt`/`writeInt`. Reuse these; only add a new `read*`/`write*` pair if the setting isn't a bool/int/string.

## 2. The interface + real implementation

- `shared/.../settings/SettingsRepository.kt` — add the `Flow<T>` (or `StateFlow<T>` if Android Telecom/BroadcastReceiver code needs synchronous `.value` access outside a coroutine — check whether the setting is read from `PassthroughInCallService`/`CallActionReceiver` first) and the `suspend fun set...(...)`.
- `shared/.../settings/SqlSettingsRepository.kt` — back it with a new string key, a sane default, same `MutableStateFlow` + init-hydration pattern as the existing fields.

## 3. Fallout — every one of these needs the new member added or the build fails

Confirmed via `grep -rl "SettingsRepository" shared androidApp --include="*.kt"` — re-run that grep to catch any new implementer added since this was written:

- `shared/src/commonMain/kotlin/.../settings/SettingsViewModel.kt` — thread into `SettingsUiState`. **If `combine()` is already at 5 flows** (kotlinx.coroutines' typed overload ceiling), don't force a 6-arg vararg combine — chain a second `.combine(newFlow) { partial, value -> ... }` on top of the existing combine's result, like `repeatedCallerBypassCount` did.
- `shared/src/commonMain/kotlin/.../home/HomeViewModel.kt` (if it reads settings)
- `shared/src/commonMain/kotlin/.../rules/domain/EvaluateIncomingCallUseCase.kt` (if the rule engine needs it)
- `shared/src/commonMain/kotlin/.../onboarding/DialerOnboardingViewModel.kt`
- `androidApp/.../telecom/PassthroughInCallService.kt`
- **One** test fake: `shared/src/commonTest/kotlin/.../testing/FakeSettingsRepository.kt`. Add the flow as a constructor parameter with a default (so no existing call site breaks) and a write-through setter, matching the other fields. `testing/FakeSettingsRepositoryTest.kt` pins that contract — extend it if the new default matters. Every ViewModel and screen test shares this one fake; there are no per-test copies left.

## 4. UI

`SettingsScreen.kt` — new toggle/control, gated visibility pattern already used for `autoAllowContacts`'s contacts-permission gate. New Compose strings needed — use `corta-spam-add-localized-string` skill for that part (all 4 locales).

## 5. If the setting feeds a `RuleDecision`/precedence change

Also touches `RuleDecision.kt` (new variant or field) and `RulePrecedenceResolver.kt`'s `ResolveContext` — that likely means a new `rule_type` CHECK value too. Use `corta-spam-sqldelight-check-migration` skill for that part.

## 6. Verify

Run `corta-spam-verify-build` (Android trio + iOS compile since this always touches `commonMain`).
