From claude-project-flow
Detect new patterns, libraries, and dependency changes from git diff and save them to feature context and knowledge base
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-project-flow:discover-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Analyze the current git diff to detect new patterns, newly introduced libraries, and dependency changes.
Analyze the current git diff to detect new patterns, newly introduced libraries, and dependency changes. Save discoveries to the feature context and index them in the knowledge base for cross-project reuse.
SessionEnd hook runs analysis and saves pending discoveriesWhen invoked manually, the analysis is interactive — the user can review, confirm, and enrich each discovery. When triggered by the hook, discoveries are saved as pending and presented at the next session start.
$ARGUMENTS — Feature name (optional, detected from branch)feature/<name>) or $ARGUMENTSproject_flow__settings_get to resolve docs pathFEATURE_DIR = <resolved_path>/features/<feature_name>/Determine the scope of changes to analyze:
git diff HEAD — current uncommitted changesgit log --oneline -20 — recent commits for contextgit diff <merge-base>..HEAD — all changes on the feature branch (if on a feature branch)Also check:
4. git diff <merge-base>..HEAD -- package.json package-lock.json requirements.txt Pipfile pyproject.toml Cargo.toml go.mod pom.xml *.csproj — dependency file changes specifically
Scan the diff for three categories:
Parse dependency file diffs to extract:
For each new dependency, note:
Analyze code changes for architectural or design patterns not previously used in the project:
For each pattern, note:
Detect shifts in coding conventions:
When invoked manually, present findings for review:
Scoperte dalla sessione:
Nuove dipendenze:
Pacchetto Versione Motivo probabile zod^3.22.0 Validazione schema input MCP tools better-sqlite3^11.0.0 Aggiornamento major (era ^10.x) Nuovi pattern:
- Upsert pattern in
mcp-server.ts— SELECT then INSERT/UPDATE instead of ON CONFLICT. Usato per feature_update.- Hook-based CLI routing in
mcp-server.ts— process.argv[2] dispatch per hook vs MCP modeCambi di convenzione:
- Nessuno rilevato
Per ogni scoperta, vuoi:
- Confermare e salvare nella knowledge base
- Ignorare (non rilevante)
- Arricchire con note aggiuntive
For each confirmed discovery, ask:
Questa scoperta dovrebbe diventare una convenzione di progetto (applicare sempre) o è specifica di questa feature?
Write/update FEATURE_DIR/context/discoveries.md:
# Discoveries: <feature_name>
## Session: <ISO date>
### New Dependencies
- **zod** (^3.22.0) — Schema validation for MCP tool inputs
- Files: `src/server/mcp-server.ts`
- Reason: Type-safe input validation
### New Patterns
- **Upsert pattern** — Check existence then INSERT or UPDATE
- Files: `src/server/mcp-server.ts:161-176`
- Context: Used for feature_update tool to handle both creation and modification
- Convention: feature-specific / project-wide
### Convention Changes
- (none)
---
<!-- Previous sessions appended below -->
When triggered by the SessionEnd hook, save to FEATURE_DIR/context/.pending-discoveries.json:
{
"session_date": "ISO date",
"dependencies": [
{
"name": "zod",
"version": "^3.22.0",
"action": "added",
"reason": "Schema validation for MCP tool inputs",
"files": ["src/server/mcp-server.ts"]
}
],
"patterns": [
{
"name": "Upsert pattern",
"description": "Check existence then INSERT or UPDATE",
"files": ["src/server/mcp-server.ts"],
"lines": "161-176",
"scope": "unknown"
}
],
"conventions": []
}
If .pending-discoveries.json exists (i.e., this was triggered from a pending review):
FEATURE_DIR/context/.pending-discoveries.jsonFor each confirmed discovery, call project_flow__knowledge_index to make it searchable cross-project.
If the discovery is marked as a project convention, also save it as a standalone knowledge file:
<knowledge_path>/conventions/<project>-<pattern-name>.md (if knowledge paths are configured)convention or pattern or libraryThis ensures that when another project introduces similar code, feature-requirements Step 3 and feature-plan Step 3c can find it.
Scoperte registrate per {feature_name}:
Tipo Quantità Indicizzate Dipendenze N si/no Pattern M si/no Convenzioni K si/no Salvate in
context/discoveries.md. {if project conventions added: "Nuove convenzioni aggiunte alla knowledge base."}
npx claudepluginhub matteovisca/claude-project-flow --plugin claude-project-flowExtracts reusable code style, workflow, architecture, and tool patterns from git history, diffs, and observations into confidence-scored instincts. Run after features, bugs, or sessions.
Scans codebase to discover coding patterns and update guardrails.md with learned conventions and anti-patterns.
Discovers git state, project structure, language/framework, and dev tooling in unfamiliar codebases. Provides structured summary with risk flags and recommendations for onboarding.