# REF-TASK-014 — Consolidate user-provisioning command composition

**Status:** Implemented  
**Kind:** Semantic tooling refactor  
**Depends on:** REF-TASK-009

## Problem and evidence

`backend/src/tooling/create-user.ts` and `seed-test-user.ts` import and compose the same input,
password hasher, user service, configuration, PostgreSQL repository, random credential support, and
email-conflict handling. Their policies differ materially: `create-user` provisions an explicit
operator identity, while `seed-test-user` is guarded test-fixture setup. The composition/error shell
is duplicated; the policy must remain separate.

## Proposed change

Extract a narrowly named internal user-provisioning runner/composition function receiving explicit
input and target policy. Keep two entry points and keep `assertTestFixtureTarget` exclusively on the
test seeder path. Centralize identical lifecycle and safe error handling only after tests prove the
same semantics.

## Constraints and sequence

Add characterization tests for both entry points and database-close/error paths, extract common
composition, then simplify each wrapper. Do not accept passwords on command lines, log secrets,
weaken database target protection, change normalization/conflict behavior, or merge production and
test commands.

## Validation

Run tooling unit tests, relevant user repository/service tests, CLI smoke tests with synthetic input
against an isolated test database, backend typecheck/build/coverage, and `pnpm quality`. Run Docker
validation if image packaging or command availability changes.

## Guidance / ADR

Update the command section of `docs/development.md` only if invocation or internal ownership needs
clarification. No ADR.
