skills/bootstrap-existing/SKILL.md
Install the agent harness into an existing codebase. Scans the project to understand its structure, then generates configuration and documentation that describes the project as it is -- without restructuring code.
npx skillsauth add alchemishty/agent-harness bootstrap-existingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are installing the agent harness into an existing codebase. The harness repository path (HARNESS_PATH) was provided by the /install-harness skill. If it was not provided, ask the user for it before proceeding.
Critical rule: Do NOT restructure existing code, rename files, or move directories. The harness adapts to the project, not the other way around. Document what exists, note improvement opportunities, but never change the source code during bootstrap.
Follow every step in order.
Read these files from the harness repository:
HARNESS_PATH/harness.schema.yamlHARNESS_PATH/references/agents-md-reference.mdHARNESS_PATH/references/architecture-reference.mdHARNESS_PATH/references/conventions-reference.mdHARNESS_PATH/references/testing-reference.mdHARNESS_PATH/references/doc-structure-reference.mdHARNESS_PATH/enforcement/enforcement-reference.mdHARNESS_PATH/hooks/hooks-reference.mdHARNESS_PATH/references/context-management-reference.mdPerform a thorough scan of the existing project. Gather all of the following information before presenting anything to the user.
Read all package manager configs found in the project root:
pubspec.yaml (Dart/Flutter) -- extract name, dependencies, dev_dependencies, SDK constraintspackage.json (Node.js) -- extract name, scripts, dependencies, devDependenciespyproject.toml / setup.py / requirements.txt (Python) -- extract project name, dependencies, tool configsgo.mod (Go) -- extract module path, Go version, dependenciesCargo.toml (Rust) -- extract package name, edition, dependenciespom.xml / build.gradle / build.gradle.kts (Java/Kotlin) -- extract group, artifact, dependenciesFrom these files, determine:
Run tree (or equivalent) on the project, excluding:
.git/, node_modules/, .dart_tool/, build/, dist/, .next/, target/, __pycache__/, .venv/, venv/Limit depth to 4 levels. Capture the output.
From the directory structure, identify:
Check for CI config files:
.github/workflows/*.yml.circleci/config.yml.gitlab-ci.ymlJenkinsfile.travis.ymlIf found, read them and extract: what steps run (lint, test, build, deploy), what triggers them, what language version is used.
Run git log --oneline -20 to see recent commit messages. Identify:
Run git branch -a --list to see branch naming patterns.
Read any existing documentation files:
README.mdAGENTS.md (if present)CLAUDE.md (if present)CONTRIBUTING.mddocs/*.md (any existing docs)Note what is already documented and what is missing.
Search for test files using language-appropriate patterns:
*_test.dart, *_test.go, test_*.py, *.test.ts, *.test.js, *.spec.ts, *.spec.jsCount how many test files exist. Note which source directories have corresponding test coverage and which do not.
Check for existing linter/formatter configuration:
.eslintrc.*, eslint.config.*ruff.toml, pyproject.toml [tool.ruff]analysis_options.yaml.prettierrc.*.golangci.ymlrustfmt.toml, .clippy.tomlPresent a structured summary of everything discovered:
Project Scan Results
Language: <detected> Framework: <detected> Database/ORM: <detected or "none detected"> Test framework: <detected or "none detected"> Linter: <detected or "none detected">
Directory structure:
<tree output, annotated with layer guesses>Existing CI: <description or "none found">
Existing tests: <N test files found, covering X directories>
Existing docs: <list or "none found">
Commit style: <detected pattern>
Identified gaps:
- <list gaps: missing tests, no CI, no docs, no linting, no .gitignore, etc.>
For each major configuration area, propose a default based on what was detected and ask the user to confirm or override. Ask these ONE AT A TIME.
Based on the project scan, I propose these commands for
harness.yaml:
- install:
<detected>- analyze:
<detected>- format:
<detected>- test:
<detected>- build:
<detected or "none">- codegen:
<detected or "none">- migrate:
<detected or "none">Are these correct? Adjust any that are wrong.
Looking at the directory structure, I see these apparent layers:
<list detected layers with their directories>I propose mapping these to the import direction enforcement as:
<layer1>-><layer2>-><layer3>-><layer4>(imports allowed left-to-right only)Does this match your architecture? Should I adjust the layers or their order?
If the architecture does not clearly map to layers, say so and ask:
The directory structure does not clearly map to strict architectural layers. Should I:
- A) Define layers based on what I see and enable import direction enforcement
- B) Skip import direction enforcement for now (you can enable it later)
If CI already exists:
I found an existing CI configuration at
<path>. I will NOT overwrite it. Should I:
- A) Leave CI as-is
- B) Add a separate harness verification workflow alongside the existing one
If no CI exists:
No CI configuration was found. Should I generate
.github/workflows/ci.ymlwith analyze, test, and build jobs?
I will generate the following documentation describing the project AS IT IS:
AGENTS.md-- agent entry point (links to docs/)docs/architecture.md-- current system architecturedocs/conventions.md-- coding patterns observed in the codebasedocs/domain.md-- domain concepts (I will need your input on this)docs/testing.md-- current testing approachdocs/decisions/001-initial-setup.md-- recording the harness installationAny existing README.md or docs will NOT be modified or overwritten.
Does this sound right?
What are the core domain entities or concepts in this project? List the main "nouns" with one-line descriptions. I will use these for
docs/domain.md.If you are unsure, I can infer some from the model files I found: <list any model class names detected from scanning model directories>
Using the confirmed decisions and the schema from HARNESS_PATH/harness.schema.yaml, generate harness.yaml in the project root.
Rules:
project.type to existing.enforcement.import_direction.layers.enforcement.file_size_limit to 300 (default).docs.max_doc_lines to 200.Write to ./harness.yaml.
Read HARNESS_PATH/references/agents-md-reference.md as your template.
Generate AGENTS.md by adapting the template to describe the project AS IT EXISTS:
docs/ files and memory/.harness.yaml (these must be commands that actually work today).docs/architecture.md.docs/conventions.md.docs/domain.md.docs/testing.md.Keep AGENTS.md under 120 lines. Do NOT describe aspirational state -- describe reality.
Create the docs and memory directory structure:
docs/
architecture.md
conventions.md
domain.md
testing.md
plans/
active/
completed/
decisions/
001-initial-setup.md
memory/
Place a .gitkeep in docs/plans/active/, docs/plans/completed/, and memory/.
Adapt HARNESS_PATH/references/architecture-reference.md to describe the ACTUAL architecture:
utils/ directory contains a mix of service logic and helper functions. Consider splitting into separate layers in the future."screens/result_screen.dart directly accesses Supabase for PDF sharing. This should be refactored through a service."Remove all <!-- ADAPT: --> comment markers.
Adapt HARNESS_PATH/references/conventions-reference.md to describe patterns ACTUALLY used in the code:
Do NOT document aspirational conventions. Document what IS. If something should change, add it as a note: "Note: some files use relative imports while others use package imports. New code should prefer package imports for consistency."
Remove all <!-- ADAPT: --> comment markers.
Generate from the user's answer in Decision 5, supplemented by what you found in model files:
Adapt HARNESS_PATH/references/testing-reference.md to describe the ACTUAL testing state:
Include only language-specific examples for the project's language. Remove all <!-- ADAPT: --> comment markers.
# 001: Agent Harness Installation
**Status:** accepted
**Context:** The agent harness was installed into this existing <language> + <framework> project to standardize agent workflows, documentation, and code quality enforcement.
**Decision:**
- Installed agent harness with documentation, enforcement rules, and skill commands
- Documented the existing architecture and conventions as-is
- Architectural layers mapped as: <layer list>
- Import direction enforcement: <enabled|disabled> (reason if disabled)
- CI: <kept existing | added new | not added>
**Alternatives considered:**
- Restructuring the codebase to match a canonical layout was rejected to avoid disruption. The harness adapts to the existing structure.
**Consequences:**
- New code should follow docs/conventions.md for consistency.
- Enforcement rules may flag existing code -- these are informational, not blockers, until the team decides to address them.
- Documentation now lives in docs/ and should be updated as the code evolves.
Create the enforcement/ directory with the same scripts as the greenfield bootstrap:
run-all.sh -- runner scriptcheck-import-direction.sh -- layer boundary enforcement (only if enabled in Decision 2)check-no-secrets.sh -- hardcoded secret detectioncheck-file-size.sh -- file size limit enforcementImportant for existing projects: The enforcement scripts should be accurate but may report existing violations. That is expected. Tell the user:
Note: Enforcement scripts may flag existing code that predates the harness installation. These are informational. You can address them incrementally or adjust the rules in
harness.yamlif they are too strict for the current codebase.
Adapt file extensions and excluded directories to match the project's actual language and structure. Make all scripts executable.
Based on Decision 3:
.github/workflows/harness-verify.yml (separate from existing CI) with analyze and test jobs..github/workflows/ci.yml with analyze, test, and build jobs appropriate to the detected language and framework.Read HARNESS_PATH/hooks/hooks-reference.md for the correct hook configuration format.
Generate .claude/settings.json with pre-commit verification hooks and a wrapper script. The format uses PreToolUse to intercept Bash tool calls:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/pre-commit-checks.sh"
}
]
}
]
}
}
Also generate .claude/hooks/pre-commit-checks.sh — a wrapper script that:
jq -r '.tool_input.command // ""'git commitjq -r '.session.cwd // "."'&& (e.g., bash enforcement/run-all.sh && ruff check src/ && pytest tests/)Replace the check commands with the actual commands from the harness.yaml you generated in Step 5.
Chain all checks with && so the commit is blocked if ANY check fails.
Ask if the user wants this created or updated now. If yes, create or merge into the existing file.
Present a complete summary of everything generated:
Bootstrap Summary
Project: <name> Type: existing Stack: <language> + <framework> + <database>
Files generated (new):
<list every new file>
memory/.gitkeep-- cross-session agent memoryEnsure
scratch/is added to.gitignore(temporary agent working files).Files NOT modified:
- All existing source code (untouched)
- <existing CI config> (preserved)
- <existing README.md> (preserved)
- <any other existing docs> (preserved)
Known issues flagged by enforcement:
- <N files exceed size limit>
- <N import direction violations>
- <N possible hardcoded secrets>
(These are informational only. Address them incrementally.)
Does this look correct? Should I proceed with committing?
Wait for explicit approval.
After approval, stage ONLY the new files generated by the harness. Do NOT stage any existing files that were modified during scanning (there should be none, but verify with git status).
Commit with message:
chore: install agent harness
- Generated harness.yaml with project configuration
- Created AGENTS.md and docs/ documentation structure
- Added enforcement rules (import direction, secrets, file size)
- Copied agent skills to .claude/commands/
Do NOT push to remote. Tell the user:
Harness installation complete. All files have been committed locally. Run
git pushwhen you are ready to push to the remote repository.Next steps:
- Review the generated docs in
docs/and correct any inaccuracies.- Run
bash enforcement/run-all.shto see the current state of enforcement.- Address any critical enforcement violations when convenient.
- Use
/implement-featureor/create-planto start your next piece of work.
documentation
Post-implementation retrospective that captures learnings to memory and proposes doc improvements
testing
Validate and fix project structure against architecture rules
tools
Migrate project scaffolding to match the latest harness version. Adds new directories (memory/, scratch/), new harness.yaml fields, and suggests AGENTS.md updates. For plugin users this handles what a plugin update cannot — project-level structure changes. For git-clone users this also updates copied skill files.
data-ai
Install the agent harness into a target project. Detects project type (greenfield vs existing), copies skills, and delegates to the appropriate bootstrap command.