feat: add flowspec doctor health-check command (TASK-606)#1249
Merged
Conversation
- Replace CLAUDE.md with cfix-style template personalised to flowspec-cli - Add AGENTS.md for Codex/compatible agents - Add .github/copilot-instructions.md for GitHub Copilot - Add .claude/workflow.md, stack.md, language.md, architecture.md, sourcecontrol.md, history.md support files - Add .claude/plans/task-606-flowspec-doctor.md implementation plan - Remove CLAUDE.md write-deny rule from settings.json (was blocking template) - Create TASK-606 backlog task for flowspec doctor command Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: jpoley <jason.poley@gmail.com>
Implements TASK-606 / closes #1221. Adds `flowspec doctor` (and `flowspec doctor --fix`) with 8 environment checks: Python version, flowspec vs latest release, backlog.md, beads, flowspec_workflow.yml validity, agent file naming, constitution.md presence, and .flowspec/ directory. Rich table output with ✅/⚠️ /❌ symbols and actionable fix hints. 23 new unit tests; full suite passes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: jpoley <jason.poley@gmail.com>
- Version comparison: replace string equality with tuple parse so 0.4.008 and 0.4.8 are treated as equivalent - check_backlog_installed: validate stdout is a dotted-integer version string before reporting PASS (rejects unexpected output) - check_beads_installed: same version-string validation on extracted token - check_workflow_config: wire in WorkflowConfig schema validation and WorkflowValidator semantic checks; imports hoisted to module level for testability - --fix upgrade-repo: check returncode and report success/failure accurately instead of printing success unconditionally - run_doctor: replace bare except Exception with specific httpx.HTTPError / TimeoutException / OSError - Tests: add _parse_version unit tests, invalid-stdout FAIL test for backlog, CliRunner tests for exit codes and --fix constitution creation - Docs: remove stale TASK-606/branch refs from CLAUDE.md, AGENTS.md, copilot-instructions; fix inline-imports rule to match codebase reality Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: jpoley <jason.poley@gmail.com>
- Add timeout=5 and TimeoutExpired catch to backlog/beads subprocess calls - Guard WorkflowValidator against non-dict yaml.safe_load() return - Catch OSError/UnicodeDecodeError in workflow config file read - Use is_dir()/is_file() instead of exists() for .flowspec, constitution, agents - Tighten _is_version_string() with regex (rejects '1.2.', '.', '1..') - Replace ASCII non-printable chars in messages (>= and --) - Re-run checks after --fix and base exit code on post-fix state - Guard _fix_constitution(): skip if no project marker present - Catch OSError on constitution write; add cwd=project_path to upgrade-repo - Add 9 new tests: timeout, empty yaml, file-vs-dir edge cases, post-fix guard Signed-off-by: jpoley <jason.poley@gmail.com>
Contributor
🟢 Security Scan Results (Advisory)
No critical or high severity issues found. How to remediate# View detailed scan results
gh run download 26330939343 -n security-scan-results-042d902db2bc4931460a15da96077d5e4910e938
# Triage findings with AI assistance
specify security triage
# Generate fix suggestions
specify security fix
# Apply fixes and re-scan
flowspec security scanSee the Security tab for detailed findings. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new flowspec doctor CLI subcommand to perform environment/setup health checks for flowspec projects and guide users toward fixes, while also adding/refreshing agent/operator guidance docs for contributors.
Changes:
- Introduces
flowspec doctorwith 8 checks, Rich table output, and--fixsupport. - Adds a dedicated
flowspec_cli.doctormodule (checks + CLI runner) and comprehensive pytest coverage. - Updates project/operator documentation and configuration files (Copilot/Claude guidance, backlog config).
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/flowspec_cli/doctor/checks.py |
Implements the 8 health checks and result model. |
src/flowspec_cli/doctor/cli.py |
Renders results, summarizes status, and implements --fix behaviors + re-check. |
src/flowspec_cli/doctor/__init__.py |
Exposes doctor module public API. |
src/flowspec_cli/__init__.py |
Registers the doctor Typer command wrapper. |
tests/test_doctor.py |
Adds unit/integration tests for checks and the CLI command behavior. |
backlog/config.yml |
Adds task_prefix configuration. |
CLAUDE.md |
Reworks Claude Code configuration/docs content. |
AGENTS.md |
Adds an entry point doc for Codex/compatible agents. |
.github/copilot-instructions.md |
Adds repo-specific GitHub Copilot contribution/runtime rules. |
.claude/workflow.md |
Adds workflow + DoD guidance. |
.claude/stack.md |
Documents stack/tooling expectations. |
.claude/sourcecontrol.md |
Documents branch/commit/PR rules. |
.claude/settings.json |
Adjusts Claude tool permissions guardrails. |
.claude/plans/task-606-flowspec-doctor.md |
Adds the implementation plan for TASK-606. |
.claude/language.md |
Adds Python language/tooling conventions. |
.claude/history.md |
Adds decision logging guidance. |
.claude/architecture.md |
Adds architecture/module-structure guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+68
to
+71
| try: | ||
| proc = subprocess.run( | ||
| ["flowspec", "upgrade-repo"], check=False, cwd=project_path | ||
| ) |
Comment on lines
+101
to
+107
| minimal = ( | ||
| "# Project Constitution\n\n" | ||
| "**Version**: 1.0.0\n" | ||
| "**Ratified**: (set date)\n\n" | ||
| "<!-- NEEDS_VALIDATION: Update with your project details -->\n\n" | ||
| "## Purpose\n\nDescribe the purpose of this project.\n" | ||
| ) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
flowspec doctorcommand with 8 environment health checks (Python version, flowspec version, backlog, beads, workflow config, agent naming convention, constitution.md, .flowspec dir)--fixflag auto-createsmemory/constitution.mdand runsflowspec upgrade-repofor fixable issues; re-runs checks post-fix so exit code reflects actual post-fix statesrc/flowspec_cli/doctor/(checks.py + cli.py); registered via@app.command("doctor")in__init__.pyWhat was hardened post-review
After Copilot review (commit
2581270) and a GPT-5.5 harsh review (commit047a821):subprocess.runcalls havetimeout=5withTimeoutExpiredcatch — hangs can't stall the commandyaml.safe_load()returningNoneor a list no longer crashesWorkflowValidatorOSError/UnicodeDecodeError, not justyaml.YAMLErrorcheck_agent_naming,check_constitution,check_flowspec_diruseis_dir()/is_file()— file/dir mismatches handled correctly_is_version_string()uses a strict regex (^\d+(\.\d+)*$) — rejects".","1..","1.2."_fix_constitution()requires at least one project marker (.flowspecdir orflowspec_workflow.yml) before writing files — prevents accidental creation in random directories_fix_constitution()catchesOSErroron writeupgrade-reposubprocess runs withcwd=project_pathTest plan
uv run pytest tests/test_doctor.py -v— 41 tests, all passuv run pytest tests/ -x -q— 3514 passed, 0 faileduv run ruff check . && uv run ruff format --check .— cleanflowspec doctorin a real project dir shows results tableflowspec doctor --fixin tmp dir with.flowspecpresent createsmemory/constitution.mdflowspec doctor --fixin a dir with no project markers skips constitution creationCloses #606
🤖 Generated with Claude Code