project-bootstrap
npx skills add https://github.com/doc-detective/agent-tools --skill project-bootstrap
Agent 安装分布
Skill 文档
Project Bootstrap
Initialize Doc Detective in a repository with documentation detection, minimal configuration, test generation, and iterative test execution with intelligent fix suggestions.
When to Use This Skill
Use this skill when:
- Setting up Doc Detective in a new or existing project
- User mentions “init”, “bootstrap”, “setup”, or “get started with Doc Detective”
- Creating initial test coverage for documentation
- Onboarding a codebase to documentation testing workflows
Workflow Overview
âââââââââââââ âââââââââââââ âââââââââââââ âââââââââââââ âââââââââââââ âââââââââââââ
â 1. Detect âââ¶â2. Configureâââ¶â3. Generateâââ¶â 4. Executeâââ¶â 5. Fix âââ¶â 6. Inject â
â(scan docs)â â(min config)â â(create â â(run tests)â â(iterative)â â(to source)â
â â â â â tests) â â â â â â â
âââââââââââââ âââââââââââââ âââââââââââââ âââââââââââââ âââââââââââââ âââââââââââââ
â â â â â â
â¼ â¼ â¼ â¼ â¼ â¼
Agent Merge/Create doc-testing Doc Detective Confidence inline-test
analysis .doc-detective skill workflow CLI execution threshold -injection
Modes of Operation
| Mode | Flag | Behavior |
|---|---|---|
| Interactive | (default) | Guided prompts, user confirmation at key steps |
| CI/Headless | --ci |
Non-interactive, sensible defaults, no prompts |
| Dry Run | --dry-run |
Show planned changes without applying |
Fix Loop Options
| Option | Default | Description |
|---|---|---|
--fix-threshold <0-100> |
80 | Flag user when confidence below this percentage |
--auto-fix |
false | Apply all fixes automatically regardless of confidence |
Phase 1: Detect Documentation
The agent scans the repository to understand documentation structure and gather context for subsequent phases. This is an agent-driven analysis, not a CLI tool invocation.
What the Agent Looks For
- Documentation directories – Common paths like
docs/,documentation/,content/,pages/,guides/ - File types – Identify supported formats and their locations
- Structure patterns – How docs are organized (flat, nested, by feature, by audience)
- Existing configuration – Check for
.doc-detective.json,doc-detective.config.js, etc. - Related tooling – Look for existing test frameworks, CI configs, build systems
Supported File Types
| Type | Extensions | Detection Signals |
|---|---|---|
| Markdown | .md, .markdown |
File extension, frontmatter patterns |
| MDX | .mdx |
File extension, JSX import patterns |
| AsciiDoc | .adoc, .asciidoc, .asc |
File extension, header patterns |
| reStructuredText | .rst |
File extension, directive patterns |
| HTML | .html, .htm |
File extension, semantic structure |
Agent Gathers
- File counts by type and location
- Directory structure overview
- Sample files for pattern analysis
- Potential procedure-heavy files (tutorials, guides, how-tos)
- Any existing test specs or config files
- README and contributing guidelines
Detection Output
Report identified documentation to user:
ð Documentation detected:
Markdown: 12 files (docs/, README.md)
MDX: 3 files (pages/)
AsciiDoc: 0 files
Total: 15 documentation files
Estimated procedures: 8-12 (based on heading analysis)
Key directories: docs/, pages/
Tutorials found: 3
How-to guides: 5
Phase 2: Configure
Generate minimal Doc Detective configuration following “smallest reasonable config” principle.
Config Strategy
- Check for existing config – Look for
.doc-detective.json,.doc-detective.yaml,doc-detective.config.js - If exists: Merge new settings, prompt user for confirmation before writing
- If new: Create file without prompting (silent creation)
Minimal Config Template
Reference doc-detective-common schema. Generate only required fields:
{
"input": ["docs/**/*.md"],
"output": ".doc-detective/results"
}
Add optional fields only when detected patterns require them:
{
"input": ["docs/**/*.md", "pages/**/*.mdx"],
"output": ".doc-detective/results",
"recursive": true,
"runTests": {
"headless": true
}
}
Config Merge Logic
When merging with existing config:
âââââââââââââââââââ
â Load existing â
â config â
ââââââââââ¬âââââââââ
â
â¼
âââââââââââââââââââ âââââââââââââââââââ
â Detect new ââââââ¶â Merge arrays â
â input paths â â (deduplicate) â
âââââââââââââââââââ ââââââââââ¬âââââââââ
â
â¼
âââââââââââââââââââ
â PROMPT USER: â
â "Merge config?" â
â Show diff â
ââââââââââ¬âââââââââ
â
ââââââââââââââ´âââââââââââââ
â¼ â¼
âââââââââââ âââââââââââ
â Accept â â Reject â
â Write â â Keep â
âââââââââââ â originalâ
âââââââââââ
CI Mode Config Handling
In --ci mode:
- New config: Create silently
- Existing config: Skip merge, use existing as-is
- Report config status in output
Phase 3: Generate Tests
Delegate to the doc-testing skill workflow for creating complete tests from source documentation.
Procedure Identification
Analyze documentation to identify testable procedures:
- Heading patterns – “How to…”, “Getting Started”, “Tutorial”, numbered steps
- Action verbs – “Click”, “Navigate”, “Enter”, “Select”, “Verify”
- Code blocks – Commands, API calls, configuration snippets
- Ordered lists – Step-by-step instructions
See references/procedure-heuristics.md for detailed LLM prompts.
Test Generation Workflow
For each identified procedure:
- Extract procedural content (steps, expected outcomes)
- Map to Doc Detective actions per
doc-testingskill rules - Generate test spec following validation requirements
- Validate before proceeding (mandatory gate per doc-testing skill)
Validation uses the doc-testing skill’s validation workflow to ensure each generated spec is valid before proceeding.
Progress Tracking
Display generation progress:
ð Generating tests...
| # | Source File | Procedure | Status |
|---|-------------|-----------|--------|
| 1 | docs/login.md | Login flow | â
Generated (6 steps) |
| 2 | docs/setup.md | Installation | â
Generated (4 steps) |
| 3 | docs/api.md | API auth | â³ Generating... |
| 4 | docs/deploy.md | Deployment | ⬠Pending |
Phase 4: Execute Tests
Run generated tests using Doc Detective CLI.
Execution Command
# Primary - Global CLI
doc-detective run --input .doc-detective/tests/ --output .doc-detective/results/
# Secondary - Docker
docker run -v "$(pwd):/app" docdetective/doc-detective:latest run --input /app/.doc-detective/tests/
# Tertiary - NPX
npx doc-detective run --input .doc-detective/tests/
Results Collection
Parse testResults-<timestamp>.json for pass/fail status:
𧪠Test Execution Results
Summary:
Tests: 8 passed, 2 failed
Steps: 45 passed, 5 failed
Failed Tests:
â docs/login.md#login-flow - Step 4: "Element 'Sign In' not found"
â docs/api.md#api-auth - Step 2: "Unexpected status code 401"
Phase 5: Fix Loop
Iteratively analyze failures and propose fixes with confidence scoring using the doc-testing skill’s fix-tests tool.
Using the Fix Tool
# Analyze failures (dry-run to preview fixes)
node ./skills/doc-testing/scripts/dist/fix-tests.js results.json --spec test-spec.json --dry-run
# Apply fixes above threshold (default 80%)
node ./skills/doc-testing/scripts/dist/fix-tests.js results.json --spec test-spec.json
# Custom threshold
node ./skills/doc-testing/scripts/dist/fix-tests.js results.json --spec test-spec.json --threshold 70
# Auto-fix all regardless of confidence
node ./skills/doc-testing/scripts/dist/fix-tests.js results.json --spec test-spec.json --auto-fix
Fix Loop Flow
âââââââââââââââââââ
â Analyze failure â
â (parse error) â
ââââââââââ¬âââââââââ
â
â¼
âââââââââââââââââââ
â Generate fix â
â + confidence % â
ââââââââââ¬âââââââââ
â
â¼
âââââââââââââââââââ
â Confidence â
â >= threshold? â
ââââââââââ¬âââââââââ
â
ââââââ´âââââ
â¼ â¼
âââââââââ âââââââââââââ
â Yes â â No â
â Apply â â FLAG USER â
â fix â â for reviewâ
âââââ¬ââââ âââââââ¬ââââââ
â â
âââââââ¬ââââââ
â
â¼
âââââââââââââââââââ
â Re-run test â
â (max 3 iters) â
âââââââââââââââââââ
Confidence Scoring
| Score | Meaning | Action |
|---|---|---|
| 90-100% | High confidence – clear fix | Auto-apply (unless below threshold) |
| 70-89% | Medium confidence – likely fix | Apply if above threshold |
| 50-69% | Low confidence – possible fix | Flag user by default |
| <50% | Very low – uncertain | Always flag user |
Common Fix Patterns
| Error Pattern | Fix Strategy | Typical Confidence |
|---|---|---|
| Element text changed | Update selector text | 85-95% |
| Timeout on find | Increase wait, add explicit wait | 70-85% |
| URL redirect | Update goTo URL | 80-90% |
| Element not found | Check alternative selectors | 50-70% |
| Auth required | Add login steps | 40-60% |
User Flagging
When confidence is below threshold (default 80%):
â ï¸ Low confidence fix (65%) for docs/login.md#login-flow step 4:
Issue: Element 'Sign In' not found
Proposed fix:
Before: { "find": "Sign In" }
After: { "find": "Log In" }
Reason: Page may have changed button text from "Sign In" to "Log In"
[A]pply fix [S]kip [E]dit manually [Q]uit fix loop
Fix Loop Limits
- Maximum 3 iterations per test
- Report “needs manual review” if fixes don’t resolve after 3 attempts
- Track fix history in results output
Phase 6: Inject Tests into Source Files
After tests pass (or fixes are applied), inject the verified tests back into the original documentation source files using the inline-test-injection skill.
Injection Workflow
âââââââââââââââââââ âââââââââââââââââââ âââââââââââââââââââ
â Verified Tests ââââââ¶â Match to Source ââââââ¶â Inject Inline â
â (passing specs) â â (track origin) â â (preview+apply) â
âââââââââââââââââââ âââââââââââââââââââ âââââââââââââââââââ
Source File Tracking
During test generation (Phase 3), track which source file each test was derived from:
{
"tests": [
{
"testId": "login-flow",
"_sourceFile": "docs/login.md",
"steps": [...]
}
]
}
Injection Options
| Option | Default | Description |
|---|---|---|
--skip-inject |
false | Skip injection phase entirely |
--inject-all |
false | Inject without per-file confirmation |
Interactive Mode Injection
For each source file with passing tests:
-
Preview changes using
inline-test-injectionskill workflow -
Prompt user for confirmation:
ð Inject tests into docs/login.md? Preview shows 6 inline comments will be added. [Y]es [N]o [A]ll remaining [S]kip all -
Apply on confirmation using the skill’s apply mode
CI Mode Injection
In --ci mode:
- Skip injection by default (tests remain as separate spec files)
- Use
--inject-allto inject without prompts - Report injection status in output
Injection Result Tracking
ð Injection Results
| Source File | Tests | Status |
|-------------|-------|--------|
| docs/login.md | 2 | â
Injected |
| docs/setup.md | 1 | â
Injected |
| docs/api.md | 1 | âï¸ Skipped (user declined) |
Comment Format by File Type
The injection tool automatically selects the correct comment format:
| File Type | Comment Syntax |
|---|---|
| Markdown | <!-- step {...} --> |
| MDX | {/* step {...} */} |
| HTML | <!-- step {...} --> |
| AsciiDoc | // (step {...}) |
| DITA/XML | <?doc-detective step {...} ?> |
Output Summary
After all phases complete:
â
Doc Detective Bootstrap Complete
Configuration:
ð Created .doc-detective.json (minimal config)
Tests Generated:
ð 8 test specs created in .doc-detective/tests/
Execution Results:
â
6 tests passed
ð§ 2 tests fixed (auto-applied)
â 0 tests need manual review
Injection:
ð 6 source files updated with inline tests
âï¸ 2 files skipped (no changes needed)
Next Steps:
⢠Run `doc-detective run` to execute tests
⢠Add to CI: `doc-detective run --ci`
⢠Inline tests will run when source files are tested
⢠See .doc-detective/results/ for detailed reports
External Resources
- Doc Detective Docs: https://doc-detective.com
- Config Schema: https://doc-detective.com/docs/references/config
- Test Structure: https://doc-detective.com/docs/get-started/tests
- Actions Reference: https://doc-detective.com/docs/category/actions
- doc-detective-common: https://github.com/doc-detective/doc-detective-common