一键导入
tfactory-init
Scaffold a .tfactory.yml + empty .tfactory/tests-catalog.json in an AIFactory repo so TFactory can start generating tests for it.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold a .tfactory.yml + empty .tfactory/tests-catalog.json in an AIFactory repo so TFactory can start generating tests for it.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Teach an AI coding assistant how to work in the TFactory codebase — the autonomous test-generation + execution platform. Covers the 4-agent pipeline, the LLM-provider abstraction (never call anthropic directly), the workspace layout, branching model, how to run the suite, and the non-negotiable conventions (i18n, no-automatic-pushes, dry-run side-effects).
Close the AIFactory ↔ TFactory loop hands-off. After TFactory tests a feature and finds problems, this drives one bounded cycle — hand the correction back to AIFactory, wait for its QA Fixer, re-test in TFactory — and stops when the run passes, the same tests keep failing (no progress), or a correction-cycle cap is hit (→ stuck for a human). One cycle per invocation; drive it with /loop for a fully autonomous test → fix → re-test loop. Epic
When TFactory's tests find problems in a feature, hand a correction back to AIFactory for revision. Reads the correction request TFactory's Triager already prepared (findings/handback_request.{md,json}), previews the target AIFactory spec, and on confirmation sends it so AIFactory's QA Fixer writes the fix on the original spec. The reverse direction of /handover-to-tfactory — together they close the AIFactory ↔ TFactory loop (epic
Hand a finished feature off to TFactory for autonomous polyglot test generation — from AIFactory, Claude Code, or any tool (via the MCP control plane, or a markdown/Gherkin/EARS acceptance-criteria file ingested with spec_sources.py). Records the task, snapshots the spec, and drives the full Planner → Gen-Functional → Executor → Evaluator → Triager pipeline across the v0.2 5-lane spine (unit / browser / api / integration / mutation) to produce a triage report + (optionally) commit tests to the feature branch + post a PR comment. Pair with /tfactory-watch under /loop to poll the task home and verify coverage — the full round-trip.
From an AIFactory project, receive a correction hand-back from TFactory (sister project). When TFactory's tests found problems, this previews the prepared correction and applies it to the original spec via AIFactory's QA Fixer (writes QA_FIX_REQUEST.md + runs the fixer). The reverse of /handover-to-tfactory.
From an AIFactory project, hand a finished spec off to TFactory (sister project) for autonomous test generation. Records the task with TFactory's MCP server; once TFactory Tasks 5-8 land, this also drives the planner→generator→executor→evaluator→triager pipeline.
| name | tfactory-init |
| description | Scaffold a .tfactory.yml + empty .tfactory/tests-catalog.json in an AIFactory repo so TFactory can start generating tests for it. |
| when_to_use | ["First-time TFactory adoption for the current repo","User says \"set up TFactory\", \"init tfactory\", \"/tfactory-init\"","The repo has no .tfactory.yml yet and the user wants the canonical scaffold"] |
| allowed_tools | ["Read","Write","Glob","Grep","Bash"] |
Scaffold the two files TFactory needs at the root of an AIFactory repo:
.tfactory.yml — declares the targets (HTTP services, k8s namespaces,
docker-compose stacks, feature-flag overlays) that tests will exercise,
plus optional test_data seed/reset hooks and an optional
evidence_policy (screenshots/video/HAR retention — Task 16)..tfactory/tests-catalog.json — the persistent cross-run catalog the
Triager (Task 11) consults to decide UPDATE-in-place vs CREATE-new per AC.
Starts empty: {"version": 1, "updated_at": "<now-Z>", "tests": []}.What this skill does NOT do: it does not register the repo with the TFactory portal, does not run the pipeline, does not write to any remote. It writes two files in the current working directory and validates them.
Trigger on:
/tfactory-initDo NOT trigger when the user is asking to run a pipeline (use
handover-to-tfactory) or to add a single test (use tfactory-add-test).
Use the Read / Glob tool to check for at least one of:
package.jsonpyproject.tomlgo.modCargo.toml.git/ directoryIf none are found, warn the user:
This directory doesn't look like a project root — no
package.json,pyproject.toml, or.git/found. Continue anyway? (y/n)
Honour their answer. Do not proceed silently.
.tfactory.yml already existsIf the file is present, read it and show the user a summary:
Found existing .tfactory.yml:
- 2 targets: api (http), cluster (kubernetes)
- default_target: api
- test_data: ./scripts/seed-test-db.sh
Overwrite? (y/N — defaults to no)
If they decline, exit cleanly with a status line:
.tfactory.yml left unchanged. Existing config: <summary>.
Ask the user, one target at a time:
What kind of target do you want to add?
- http — HTTP/HTTPS service (REST API or browser app)
- kubernetes — Service inside a k8s cluster
- docker_compose — Local stack via docker-compose
- feature_flag — Feature-flag overlay (GrowthBook / LaunchDarkly / Split / Unleash)
- done — Finish target collection
For each target type, collect:
http target:
name (slug, lower-case, e.g. api / web-staging)base_url (full https URL)bearer / basic / oauth2_client_credentials / none
bearer: token_env (env-var NAME, e.g. STAGING_API_TOKEN)basic: username_env + password_envoauth2_client_credentials: token_url + client_id_env + client_secret_envhealth_check? path + expect_status (default /healthz 200)openapi_spec? path to OpenAPI YAML (optional; helps the Planner for API lane)kubernetes target:
name, context (kubectl context), namespaceserviceaccount (token_file path) or mtls (client_cert + client_key + optional ca_cert)service, port, port_forward (bool)docker_compose target:
namecompose_file (path relative to repo root, e.g. docker-compose.test.yml)services (list — at least one)wait_for (list of {url, timeout_seconds, expect_status} — typically the
app's ready endpoint)feature_flag target:
name, flag_key, service (growthbook | launchdarkly | split | unleash)bearer (token_env is the SDK key env var) or noneDecision 7 of the v0.2 design spec: auth fields store the env-var name (e.g.
token_env: STAGING_API_TOKEN). NEVER prompt the user for the secret value. NEVER write the secret value into.tfactory.yml. The Executor resolves env-vars at runtime viatfactory_yml.secrets.
After targets, ask:
Add a
default_target? (choose from the names you just declared, or press enter to skip)
Add
test_dataseed/reset hooks?
seed_command: shell command to seed the DB (e.g../scripts/seed-test-db.sh)reset_command: shell command to reset (e.g../scripts/reset-test-db.sh)fixtures_dir: optional path to a fixtures directory
Add an
evidence_policy? (Task 16 placeholder — accept any sub-keys; the portal will populate this later)
Render the collected data as a .tfactory.yml YAML file matching the
TFactoryConfig Pydantic schema (apps/backend/tfactory_yml/schema.py).
Example layout:
version: 1
targets:
- name: api
type: http
base_url: https://api.staging.example.com
auth:
type: bearer
token_env: STAGING_API_TOKEN
health_check:
path: /healthz
expect_status: 200
default_target: api
test_data:
seed_command: ./scripts/seed-test-db.sh
Before writing the file, validate it by running:
PYTHONPATH=apps/backend python3 -c "
from pathlib import Path
from tfactory_yml import load_tfactory_yml
load_tfactory_yml(Path('.'))
print('OK')
"
(If you're running this skill against a project that doesn't have TFactory
checked out alongside, substitute the absolute path to a TFactory checkout
on the PYTHONPATH.) If validation prints OK, write the file. If it
raises TFactoryYmlError, show the user the error message and ask them
to correct the offending field — do NOT save an invalid config.
If .tfactory/tests-catalog.json does NOT already exist, write:
{
"version": 1,
"updated_at": "<UTC ISO-8601 timestamp with Z suffix>",
"tests": []
}
If it already exists, do NOT overwrite — the catalog accumulates entries across runs and must survive re-init. Just log:
.tfactory/tests-catalog.json already present (N entries) — preserved.
Print a concise summary:
✓ Wrote .tfactory.yml (2 targets, default=api)
✓ Wrote .tfactory/tests-catalog.json (empty)
Next steps:
• Add `.tfactory/` to `.gitignore` if you don't want to commit per-spec
workspace data (but DO commit `.tfactory.yml` and `.tfactory/tests-catalog.json`)
• Hand a feature off to TFactory: /handover-to-tfactory
• Add a single test from a template: /tfactory-from-template
• Add a single test by symbol: /tfactory-add-test
.tfactory.yml already exists and user declined overwrite → exit
cleanly, leave files untouched.load_tfactory_yml → surface the
TFactoryYmlError (which carries .field + .reason) to the user, ask
for correction, retry validation. Never write an invalid file.PYTHONPATH doesn't resolve tfactory_yml → skip the strict
validation step and warn the user that the config was written without a
schema check; suggest they run load_tfactory_yml themselves.mcp__tfactory__project_create)..gitignore, package.json, or any other repo file
beyond .tfactory.yml + .tfactory/tests-catalog.json.