feat: add flowspec doctor health-check command#1248
Closed
jpoley wants to merge 2 commits into
Closed
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>
Contributor
🟢 Security Scan Results (Advisory)
No critical or high severity issues found. How to remediate# View detailed scan results
gh run download 26329325597 -n security-scan-results-9ba4341428c9fef82c2b8a3bfc3e1e60a16a5e8f
# 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 command intended to diagnose common environment/setup issues early, along with supporting documentation and configuration updates to guide agent/tooling workflows.
Changes:
- Introduces
flowspec doctorcommand with 8 health checks, Rich table output,--fixsupport, and non-zero exit on failures. - Adds unit tests for the individual health checks.
- Updates/introduces various repo guidance files (
CLAUDE.md,AGENTS.md,.github/copilot-instructions.md,.claude/*) and tweaks Backlog config.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_doctor.py | Adds unit tests for the 8 doctor checks and the aggregate runner. |
| src/flowspec_cli/doctor/cli.py | Implements run_doctor, table rendering, summary, --fix behavior, and exit codes. |
| src/flowspec_cli/doctor/checks.py | Implements the 8 health checks and returns standardized CheckResults. |
| src/flowspec_cli/doctor/init.py | Exposes doctor module symbols (run_doctor, statuses, etc.). |
| src/flowspec_cli/init.py | Registers flowspec doctor as a top-level Typer command. |
| CLAUDE.md | Rewrites operator guidance/guardrails and repo reference content. |
| AGENTS.md | Adds an agent entrypoint document and task-specific guidance. |
| .github/copilot-instructions.md | Adds GitHub Copilot repo instructions and “current focus” guidance. |
| .claude/workflow.md | Adds workflow/DoD/planning guidance for tasks. |
| .claude/stack.md | Adds stack/tooling reference (Python/uv/ruff/pytest/etc.). |
| .claude/sourcecontrol.md | Adds branching/commit/PR workflow rules. |
| .claude/settings.json | Updates Claude settings deny-list (notably removes CLAUDE.md protections). |
| .claude/plans/task-606-flowspec-doctor.md | Adds task plan documenting intended design/behavior for doctor. |
| .claude/language.md | Adds Python/ruff/pytest conventions and patterns. |
| .claude/history.md | Adds decision-log guidance and JSONL format reference. |
| .claude/architecture.md | Adds repo architecture overview and command/module conventions. |
| backlog/config.yml | Adds task_prefix: "task" setting. |
Comments suppressed due to low confidence (1)
.claude/settings.json:22
- The deny-list no longer blocks Write/Edit/Delete for
CLAUDE.md. If CLAUDE.md is intended to be a protected guardrails/config file (similar tomemory/constitution.md), these permissions should likely be re-added after this edit so future agent sessions can’t unintentionally mutate core instructions.
"Delete(./.env)",
"Delete(./.env.*)",
"Delete(./secrets/**)",
"Write(./memory/constitution.md)",
"Edit(./memory/constitution.md)",
"Delete(./memory/constitution.md)",
"Write(./uv.lock)",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+47
to
+66
| def check_flowspec_version(current: str, latest: Optional[str]) -> CheckResult: | ||
| """Check whether the installed flowspec version is up to date.""" | ||
| if latest is None: | ||
| return CheckResult( | ||
| name="flowspec version", | ||
| status=CheckStatus.WARN, | ||
| message=f"flowspec v{current} (could not check latest)", | ||
| ) | ||
| if current == latest: | ||
| return CheckResult( | ||
| name="flowspec version", | ||
| status=CheckStatus.PASS, | ||
| message=f"flowspec v{current} (up to date)", | ||
| ) | ||
| return CheckResult( | ||
| name="flowspec version", | ||
| status=CheckStatus.WARN, | ||
| message=f"flowspec v{current} — v{latest} available", | ||
| fix_cmd="flowspec upgrade", | ||
| ) |
Comment on lines
+69
to
+89
| def check_backlog_installed() -> CheckResult: | ||
| """Check that the backlog CLI is installed.""" | ||
| try: | ||
| result = subprocess.run( | ||
| ["backlog", "--version"], capture_output=True, text=True, check=False | ||
| ) | ||
| if result.returncode == 0: | ||
| version = result.stdout.strip() | ||
| return CheckResult( | ||
| name="backlog.md", | ||
| status=CheckStatus.PASS, | ||
| message=f"backlog.md v{version}", | ||
| ) | ||
| except FileNotFoundError: | ||
| pass | ||
| return CheckResult( | ||
| name="backlog.md", | ||
| status=CheckStatus.FAIL, | ||
| message="backlog not found", | ||
| fix_cmd="npm install -g backlog.md", | ||
| ) |
Comment on lines
+92
to
+117
| def check_beads_installed() -> CheckResult: | ||
| """Check that the beads CLI is installed.""" | ||
| try: | ||
| result = subprocess.run( | ||
| ["bd", "--version"], capture_output=True, text=True, check=False | ||
| ) | ||
| if result.returncode == 0: | ||
| output = result.stdout.strip() | ||
| version = output | ||
| if output.startswith("bd version "): | ||
| parts = output.split() | ||
| if len(parts) >= 3: | ||
| version = parts[2] | ||
| return CheckResult( | ||
| name="beads", | ||
| status=CheckStatus.PASS, | ||
| message=f"beads v{version}", | ||
| ) | ||
| except FileNotFoundError: | ||
| pass | ||
| return CheckResult( | ||
| name="beads", | ||
| status=CheckStatus.FAIL, | ||
| message="beads (bd) not found", | ||
| fix_cmd="npm install -g @jpoley/beads", | ||
| ) |
Comment on lines
+120
to
+144
| def check_workflow_config(project_path: Path) -> CheckResult: | ||
| """Check that flowspec_workflow.yml exists and is valid YAML.""" | ||
| config_path = project_path / "flowspec_workflow.yml" | ||
| if not config_path.exists(): | ||
| return CheckResult( | ||
| name="flowspec_workflow.yml", | ||
| status=CheckStatus.FAIL, | ||
| message="flowspec_workflow.yml not found", | ||
| fix_cmd="flowspec init --here", | ||
| ) | ||
| try: | ||
| content = config_path.read_text(encoding="utf-8") | ||
| yaml.safe_load(content) | ||
| return CheckResult( | ||
| name="flowspec_workflow.yml", | ||
| status=CheckStatus.PASS, | ||
| message="flowspec_workflow.yml present and valid", | ||
| ) | ||
| except yaml.YAMLError as exc: | ||
| return CheckResult( | ||
| name="flowspec_workflow.yml", | ||
| status=CheckStatus.FAIL, | ||
| message=f"flowspec_workflow.yml parse error: {exc}", | ||
| fix_cmd="flowspec init --here", | ||
| ) |
Comment on lines
+56
to
+57
| subprocess.run(["flowspec", "upgrade-repo"], check=False) | ||
| console.print(" [green]✓[/green] upgrade-repo ran") |
Comment on lines
+7
to
+12
| ## Project | ||
| **Name:** flowspec-cli | ||
| **Repo:** github.com/jpoley/flowspec | ||
| **Purpose:** CLI toolkit that initialises, upgrades, and orchestrates AI agent workflows using Spec-Driven Development (SDD). Ships as `flowspec` (and legacy alias `specify`). | ||
| **Current focus:** TASK-606 — `flowspec doctor` health-check command, branch `galway/task-606/flowspec-doctor` | ||
|
|
Comment on lines
+54
to
+71
| **TASK-606** — `flowspec doctor` setup health-check command | ||
| Plan: `.claude/plans/task-606-flowspec-doctor.md` | ||
| Branch: `galway/task-606/flowspec-doctor` | ||
|
|
||
| ### What to build | ||
| ``` | ||
| src/flowspec_cli/doctor/ | ||
| ├── __init__.py — exports run_doctor() | ||
| ├── checks.py — CheckResult dataclass + 8 check functions | ||
| └── cli.py — Typer command + run_doctor() | ||
| tests/test_doctor.py — ~15 unit tests | ||
| ``` | ||
| Register in `src/flowspec_cli/__init__.py` near line 9179 as `@app.command("doctor")`. | ||
|
|
||
| ### Test command | ||
| ```bash | ||
| uv run pytest tests/ -x -q | ||
| ``` |
| - Ruff: formatter + linter, line length 88. | ||
| - Type hints required on public API functions. | ||
| - `pathlib.Path` for all file paths, never `os.path`. | ||
| - All imports at module level — no inline imports. |
Comment on lines
+34
to
+35
| TASK-606 — `flowspec doctor` health-check command. Branch: `galway/task-606/flowspec-doctor`. | ||
| Plan: `.claude/plans/task-606-flowspec-doctor.md`. |
Comment on lines
+84
to
+97
| def run_doctor(project_path: Path, fix: bool = False) -> None: | ||
| """Run all health checks and print results.""" | ||
| from flowspec_cli import __version__ | ||
|
|
||
| try: | ||
| from flowspec_cli import REPO_NAME, REPO_OWNER, get_github_latest_release | ||
|
|
||
| latest = get_github_latest_release(REPO_OWNER, REPO_NAME) | ||
| except Exception: | ||
| latest = None | ||
|
|
||
| results = run_all_checks( | ||
| project_path, current_version=__version__, latest_version=latest | ||
| ) |
Owner
Author
|
Closing to address Copilot review findings before reopening as a clean PR. |
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 doctorCLI command that checks the environment and surfaces setup problems before they cause failuresflowspec_workflow.ymlpresent/valid, agent file naming convention,memory/constitution.mdpresent,.flowspec/directory presentflowspec doctor --fixauto-creates a minimal constitution and runsupgrade-repofor agent naming issues; prints manual commands for other failuressrc/flowspec_cli/doctor/(checks.py, cli.py, init.py); registered as top-level@app.command("doctor")Closes #1221 / TASK-606.
Test plan
uv run pytest tests/test_doctor.py -v→ 23 passeduv run pytest tests/ -x -q→ 3496 passed, 41 skippeduv run ruff check .→ 0 errorsuv run ruff format --check .→ 0 reformatsflowspec doctorruns and prints formatted output with correct pass/warn/fail per checkflowspec doctor --fixruns without error; creates constitution if missing🤖 Generated with Claude Code