
Project Discovery
- 65 installs
- 49 repo stars
- Updated August 4, 2026
- laurigates/claude-plugins
Helps with ai & agent building tasks.
About
project-discovery is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- project-discovery
- AI & Agent Building
- AI-coding skill
Project Discovery by the numbers
- 65 all-time installs (skills.sh)
- Ranked #6,042 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/laurigates/claude-plugins --skill project-discoveryAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 65 |
|---|---|
| repo stars | ★ 49 |
| Last updated | August 4, 2026 |
| Repository | laurigates/claude-plugins ↗ |
What it does
Helps with ai & agent building tasks.
Files
Project Discovery
When to Use This Skill
| Use this skill when... | Use project-continue instead when... |
|---|---|
| Entering an unfamiliar codebase and need orientation on language/tooling | Resuming known work on a familiar project from PRDs and feature tracker |
| Reasoning shows uncertainty phrases ("not sure what this does") | Already have a clear next task and just need to continue executing |
| Onboarding a fresh clone where build/test commands are unknown | Use project-init instead when scaffolding a brand-new project from scratch |
Systematic project orientation to understand codebase state before making changes. Prevents working on incorrect assumptions by establishing clear context about git state, project structure, and development tooling.
Core Expertise
Automatic Activation Detection:
- Detects uncertainty in Claude's reasoning or responses
- Activates on manual user requests for orientation
- Focuses on git repositories only
Discovery Capabilities:
- Git state analysis (branch, changes, remote sync, commit history)
- Project type identification (language, framework, monorepo detection)
- Development tooling discovery (build, test, lint, CI/CD)
- Documentation quick scan (README, setup instructions)
- Risk flag identification (uncommitted work, branch divergence)
Output:
- Structured summary of project state
- Critical risk flags highlighted
- Actionable next-step recommendations
- 2-3 minute discovery timeframe
When This Skill Activates
Automatic Triggers
This skill automatically activates when Claude's internal reasoning or responses contain uncertainty phrases like:
- "I should first understand..."
- "Let me check the project..."
- "Not sure about the structure..."
- "I need to understand..."
- "Before proceeding, let me..."
- "I'm uncertain about..."
- "Let me investigate the project..."
Rationale: These phrases indicate Claude is working on incomplete context, which can lead to incorrect assumptions, wrong commands, or inappropriate file edits.
Manual Invocation
Users can explicitly request project discovery with keywords:
- "orient yourself"
- "discover the project"
- "understand this codebase"
- "what's the project state?"
- "analyze the project structure"
- "give me project context"
When NOT to Activate
Do NOT activate this skill when:
- Claude has clear context and is confidently executing a specific task
- User is asking about specific code that Claude has already analyzed
- Current conversation already established project context
- Working in a non-git directory (this skill is git-focused)
Quick Discovery (Recommended)
For fast, consistent project orientation, run the bundled discovery script:
bash "${CLAUDE_PLUGIN_ROOT}/skills/project-discovery/scripts/discover.sh"This replaces the manual 5-step process with a single execution that outputs structured data covering git state, project type, tooling, documentation, and risk assessment.
For the full manual workflow (5 steps with all commands, risk flags, the summary template, error handling for non-git / empty / large-monorepo / missing-docs cases, and the underlying rationale), see REFERENCE.md.
Integration with Other Skills
Related Skills
- git-commit-workflow: Use after discovering conventional commit patterns
- chezmoi-expert: If project is a dotfiles repo (detects chezmoi.toml)
- git-security-checks: Run if pre-commit hooks detected
- Explore agent: Delegate to this agent if deeper codebase exploration needed beyond initial orientation
When to Delegate
After project discovery, if user asks for deeper investigation:
- "How does authentication work?" → Use
Exploreagent - "Review this code for security" → Use
security-auditagent - "Understand the architecture" → Use
code-analysisagent
Project discovery establishes baseline context; specialized skills handle deep investigation.
Quick Reference: Discovery Commands
Essential Git Commands
git branch --show-current # Current branch
git status --short --branch # Git state summary
git log --oneline -n 10 # Recent commits
git rev-list --count HEAD...@{u} # Commits ahead/behind remoteProject type, tooling, and docs
scripts/discover.sh already detects project type (manifest files), tooling (npm scripts, Make targets, CI workflows), and documentation. Read those signals from the script's structured output, or use the Glob/Grep/Read tools directly rather than hand-coding ls/find/head shells — see REFERENCE.md for the full manual command set.
---
Example Output
See examples.md for complete discovery outputs for:
- Python project with pytest + ruff + GitHub Actions
- JavaScript/TypeScript project with npm + ESLint + Vitest
- Rust project with cargo + clippy + no CI
- Monorepo with multiple sub-projects
- Project with uncommitted changes (risk flags)
- Clean project ready for work
---
For detailed command reference and more examples, see `discovery-commands.md` and `examples.md`.
Project Discovery — Reference
Detailed manual workflow, error-handling guidance, best practices, and rationale for project-discovery. The script scripts/discover.sh covers the same ground; this reference is the fallback when the script is unavailable.
Systematic Discovery Workflow (Manual Alternative)
When the script is unavailable, execute this 5-step systematic discovery process. Complete all steps before providing the summary.
---
Step 1: Analyze git state
Goal: Understand version control state to prevent data loss and branch confusion.
Commands to Run:
# Current branch and tracking info
git branch --show-current
git status --short --branch
# Uncommitted changes summary
git status --porcelain | wc -l
git diff --stat
git diff --staged --stat
# Remote sync status
git rev-list --left-right --count HEAD...@{u} 2>/dev/null || echo "No tracking branch"
# Recent commit history (last 10 commits)
git log --oneline --decorate -n 10
# Check for conventional commits pattern
git log --oneline -n 20 | grep -E "^[a-f0-9]+ (feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(.+\))?:"What to Extract:
- Current branch name
- Number of uncommitted files (staged + unstaged)
- Number of commits ahead/behind remote
- Recent commit messages (look for patterns, conventional commits)
- Last commit author and date
- Whether working tree is clean
Risk Flags:
- ⚠️ Uncommitted changes exist (risk of data loss)
- ⚠️ Branch diverged from remote (conflicts possible)
- ⚠️ On main/master branch (should work on feature branch)
- ⚠️ Detached HEAD state (not on any branch)
---
Step 2: Detect project type
Goal: Identify language, framework, and project structure to use correct tooling.
Commands to Run:
# Check for project manifests (determines language/ecosystem)
ls -la | grep -E "(package\.json|Cargo\.toml|pyproject\.toml|go\.mod|Gemfile|pom\.xml|build\.gradle|composer\.json|mix\.exs)"
# Detect monorepo structure
find . -maxdepth 3 -name "package.json" -o -name "Cargo.toml" -o -name "pyproject.toml" | head -20
# Check directory structure
ls -d */ 2>/dev/null | head -20
# Find entry points (main files)
find . -maxdepth 2 -name "main.*" -o -name "index.*" -o -name "app.*" -o -name "__init__.py" 2>/dev/null | head -10Project Manifest Detection:
| File | Language/Ecosystem | Common Frameworks |
|---|---|---|
package.json | JavaScript/TypeScript | React, Vue, Next.js, Express, Node |
Cargo.toml | Rust | Actix, Rocket, Tokio |
pyproject.toml | Python | Django, FastAPI, Flask |
go.mod | Go | Gin, Echo, Fiber |
Gemfile | Ruby | Rails, Sinatra |
pom.xml / build.gradle | Java | Spring, Quarkus |
composer.json | PHP | Laravel, Symfony |
mix.exs | Elixir | Phoenix |
What to Extract:
- Primary language(s) and version(s)
- Framework detected (check package.json dependencies, Cargo.toml deps, etc.)
- Monorepo vs single-project (multiple manifests = monorepo)
- Common directory patterns (src/, lib/, tests/, docs/)
- Entry point files
Additional Framework Detection:
# JavaScript/TypeScript frameworks
grep -E "(react|vue|next|nuxt|svelte|angular|express|fastify|nest)" package.json 2>/dev/null
# Python frameworks
grep -E "(django|fastapi|flask|pyramid)" pyproject.toml 2>/dev/null
# Check for specific config files
ls | grep -E "(next\.config|vite\.config|webpack\.config|tsconfig|jest\.config|pytest\.ini|setup\.py)"---
Step 3: Discover development tooling
Goal: Identify build system, test framework, linters, and CI/CD to run correct commands.
Commands to Run:
# Build system detection
ls -la | grep -E "(Makefile|Justfile|package\.json|Cargo\.toml|pyproject\.toml)"
# Check package.json scripts (if JS/TS project)
jq -r '.scripts | keys[]' package.json 2>/dev/null | head -20
# Check Makefile targets
grep "^[a-zA-Z0-9_-]*:" Makefile 2>/dev/null | cut -d: -f1 | head -20
# Test framework detection
find . -maxdepth 3 -name "*test*" -o -name "*spec*" 2>/dev/null | grep -E "\.(js|ts|py|rs|go)$" | head -10
# Linter/formatter detection
ls -la | grep -E "(\.eslintrc|\.prettierrc|ruff\.toml|\.flake8|rustfmt\.toml|\.golangci)"
# Pre-commit hooks
ls -la .git/hooks/ 2>/dev/null | grep -v sample
cat .pre-commit-config.yaml 2>/dev/null | head -20
# CI/CD detection
ls -la .github/workflows/ 2>/dev/null | grep "\.yml"
ls -la .gitlab-ci.yml 2>/dev/null
ls -la .circleci/config.yml 2>/dev/nullWhat to Extract:
Build System:
- npm scripts (if package.json)
- Make targets (if Makefile)
- Cargo commands (if Rust)
- Python build tools (setuptools, poetry, hatchling)
Test Framework:
- Jest, Vitest, Mocha (JS/TS)
- pytest, unittest (Python)
- cargo test (Rust)
- go test (Go)
- Test file naming conventions
Linters/Formatters:
- ESLint, Prettier (JS/TS)
- ruff, black, flake8 (Python)
- clippy, rustfmt (Rust)
- golangci-lint (Go)
Pre-commit Hooks:
- Present or absent
- Configured tools (from .pre-commit-config.yaml)
CI/CD:
- GitHub Actions (list workflow files)
- GitLab CI
- CircleCI
- Other CI systems
---
Step 4: Scan documentation
Goal: Understand project purpose and setup requirements from documentation.
Commands to Run:
# README first section (project purpose)
head -50 README.md 2>/dev/null
# Check for common documentation files
ls -la | grep -E "(README|CONTRIBUTING|CHANGELOG|LICENSE|ARCHITECTURE|docs/)"
# Look for setup/installation instructions in README
grep -A 10 -i "install\|setup\|getting started" README.md 2>/dev/null | head -30
# Check for documentation directory
ls -la docs/ 2>/dev/null | head -20What to Extract:
- Project name and one-sentence description
- Primary purpose (web app, library, tool, etc.)
- Key features or capabilities
- Setup/installation instructions present?
- CONTRIBUTING.md exists? (indicates contributor guidance)
- Documentation directory structure
Documentation Quality Indicators:
- ✅ README with clear description and setup steps
- ✅ CONTRIBUTING.md (good for contributions)
- ✅ CHANGELOG.md (indicates release management)
- ✅ docs/ directory (comprehensive documentation)
- ⚠️ Missing README or minimal content
- ⚠️ No setup instructions
---
Step 5: Summarize state and recommend next actions
Goal: Synthesize all findings into actionable summary with risk flags.
Output Format Template:
# Project Discovery Summary
## 📊 Project Overview
- **Type**: [Language] / [Framework] / [Monorepo or Single-project]
- **Purpose**: [One-sentence description from README]
- **Entry Point**: [Main file or startup command]
## 🔀 Git State
- **Branch**: [current-branch-name]
- **Status**: [X files changed, Y staged, Z unstaged] OR [Working tree clean]
- **Remote Sync**: [X commits ahead, Y commits behind] OR [In sync with origin]
- **Last Commit**: [Hash] - [Message] by [Author] ([Time ago])
- **Commit Style**: [Conventional commits detected] OR [Free-form commits]
### ⚠️ Risk Flags
[List any risk flags found in Phase 1, or state "None - safe to proceed"]
## 🛠️ Development Tooling
### Build System
- [Build command: npm run build / cargo build / make / etc.]
### Test Framework
- [Test command: npm test / pytest / cargo test / etc.]
- [Test file location: tests/ or src/__tests__/ or *_test.rs]
### Code Quality
- **Linters**: [ESLint / ruff / clippy / etc.]
- **Formatters**: [Prettier / black / rustfmt / etc.]
- **Pre-commit Hooks**: [Configured] OR [Not configured]
### CI/CD
- [GitHub Actions: X workflows] OR [No CI/CD detected]
- [Workflows: build.yml, test.yml, deploy.yml]
## 📚 Documentation
- **README**: [Present with setup instructions] OR [Missing or minimal]
- **CONTRIBUTING**: [Present] OR [Not present]
- **Other Docs**: [docs/ directory, ARCHITECTURE.md, etc.]
## ✅ Recommendations
[Based on findings, provide 2-4 actionable recommendations, such as:]
1. **Commit uncommitted work** - You have X unstaged files that could be lost
2. **Create feature branch** - Currently on main; create a feature branch before making changes
3. **Pull latest changes** - X commits behind origin/main
4. **Run tests before changes** - Use `[test-command]` to establish baseline
5. **Review setup instructions** - Check README.md for dependencies and setup steps
6. **Safe to proceed** - Working tree clean, branch in sync, tooling detected
---
**Discovery completed in [time]. Ready to work with clear context.**Risk Flag Priority:
- 🔴 Critical: Uncommitted changes + on main branch + behind remote
- 🟡 Warning: Any single risk flag (uncommitted changes, diverged branch, etc.)
- 🟢 Safe: Clean working tree, feature branch, in sync with remote
Error Handling & Edge Cases
Non-Git Directory
If git status fails (not a git repository):
⚠️ **Not a Git Repository**
This skill is designed for git repositories only. This directory does not have a `.git` folder.
**Recommendations:**
1. Initialize git: `git init`
2. Or navigate to a git repository
3. Or use manual exploration tools (ls, find, etc.) for non-git projectsEmpty Repository
If git repo exists but has no commits:
ℹ️ **Empty Git Repository**
This is a newly initialized git repository with no commits yet.
**Recommendations:**
1. Make initial commit to establish git history
2. Check README.md for project purpose (if exists)
3. Proceed with caution - no version history to referenceLarge Monorepo Performance
If discovery takes >30 seconds (e.g., huge monorepo):
ℹ️ **Large Repository Detected**
Discovery is taking longer than expected. For large monorepos, consider:
1. **Focus on specific subdirectory**: Navigate to relevant sub-project first
2. **Use targeted exploration**: Ask specific questions rather than full discovery
3. **Check monorepo docs**: Often have READMEs explaining structureMissing Documentation
If no README.md or minimal content:
⚠️ **Documentation Sparse**
No README.md found or content is minimal.
**Recommendations:**
1. Check commit messages for context about project purpose
2. Examine directory structure and entry points
3. Look for inline code comments
4. Ask user for project context if availableBest Practices
Before Making Any Changes
1. Always run project discovery when entering an unfamiliar codebase 2. Check git state to preserve uncommitted work 3. Identify tooling to use correct build/test commands 4. Read README for setup requirements and project conventions
Discovery Efficiency
1. Complete all 5 steps even if early steps reveal issues (comprehensive context prevents follow-up questions) 2. Highlight risk flags prominently in summary 3. Provide actionable recommendations specific to the project state 4. Keep discovery focused (2-3 minutes; defer deep investigation to specialized skills)
Integration with Workflow
1. Discovery first, then action - Establish context before editing files 2. Update mental model - If discovery reveals surprises, re-evaluate planned approach 3. Respect git state - Don't ignore risk flags; address them before proceeding
Rationale: Why Systematic Discovery Matters
Problem: Claude often works on incomplete assumptions:
- Editing wrong branch
- Using incorrect build commands
- Overwriting uncommitted work
- Missing critical tooling (tests, linters)
Solution: Systematic orientation establishes:
- ✅ Clear git state (prevent data loss)
- ✅ Correct project type (use right tools)
- ✅ Available tooling (run proper commands)
- ✅ Risk awareness (flag dangerous states)
Result: Confident, accurate work on solid foundation rather than shaky assumptions.
#!/usr/bin/env bash
# Skill Script Opportunity Analyzer
# Scans all plugin skills and identifies candidates for supporting scripts.
# Usage: bash analyze-skills.sh [plugin-name]
#
# Evaluates: bash block count, workflow phases, context-gathering patterns,
# existing scripts, and skill size. Outputs structured recommendations.
set -uo pipefail
REPO_ROOT="${1:-.}"
SPECIFIC_PLUGIN="${2:-}"
echo "=== SKILL SCRIPT ANALYSIS ==="
echo ""
# Find all skills
if [ -n "$SPECIFIC_PLUGIN" ]; then
skill_dirs=$(find "$REPO_ROOT/$SPECIFIC_PLUGIN/skills" -name "SKILL.md" -o -name "skill.md" 2>/dev/null)
else
skill_dirs=$(find "$REPO_ROOT" -path "*-plugin/skills/*/SKILL.md" -o -path "*-plugin/skills/*/skill.md" 2>/dev/null | sort)
fi
total_skills=0
with_scripts=0
candidates=0
echo "--- CURRENT SCRIPT COVERAGE ---"
echo ""
# Report skills that already have scripts
for skill_file in $skill_dirs; do
skill_dir=$(dirname "$skill_file")
skill_name=$(basename "$skill_dir")
plugin_name=$(echo "$skill_dir" | grep -oE "[^/]*-plugin/" | tail -1 | tr -d '/')
total_skills=$((total_skills + 1))
if [ -d "$skill_dir/scripts" ]; then
with_scripts=$((with_scripts + 1))
script_count=$(find "$skill_dir/scripts" -type f 2>/dev/null | wc -l | tr -d ' ')
scripts=$(find "$skill_dir/scripts" -type f -exec basename {} \; 2>/dev/null | tr '\n' ', ')
scripts=${scripts%,}
echo " HAS_SCRIPTS: $plugin_name/$skill_name ($script_count: $scripts)"
fi
done
echo ""
echo "COVERAGE: $with_scripts/$total_skills skills have scripts"
echo ""
# Analyze candidates
echo "--- CANDIDATES FOR SCRIPTS ---"
echo ""
for skill_file in $skill_dirs; do
skill_dir=$(dirname "$skill_file")
skill_name=$(basename "$skill_dir")
plugin_name=$(echo "$skill_dir" | grep -oE "[^/]*-plugin/" | tail -1 | tr -d '/')
# Skip skills that already have scripts
[ -d "$skill_dir/scripts" ] && continue
# Metrics (tr -d ' ' ensures clean integers)
line_count=$(wc -l < "$skill_file" | tr -d ' ')
bash_blocks=$(grep -c '```bash' "$skill_file" 2>/dev/null || true)
bash_blocks=${bash_blocks:-0}
bash_commands=$(grep -cE "^\s*(git |npm |bun |cargo |pip |pytest|ruff |black |eslint|biome |kubectl |helm |docker |terraform |gh |find |grep |ls |cat |head |jq |yq )" "$skill_file" 2>/dev/null || true)
bash_commands=${bash_commands:-0}
phases=$(grep -cE "^###? Phase|^###? Step" "$skill_file" 2>/dev/null || true)
phases=${phases:-0}
workflow_sections=$(grep -cE "^## .*(Workflow|Process|Pipeline|Execution)" "$skill_file" 2>/dev/null || true)
workflow_sections=${workflow_sections:-0}
context_patterns=$(grep -cE "(git status|git diff|git log|gh pr|gh issue|git branch)" "$skill_file" 2>/dev/null || true)
context_patterns=${context_patterns:-0}
# Ensure clean integers
bash_blocks=$(echo "$bash_blocks" | tr -dc '0-9')
bash_commands=$(echo "$bash_commands" | tr -dc '0-9')
phases=$(echo "$phases" | tr -dc '0-9')
context_patterns=$(echo "$context_patterns" | tr -dc '0-9')
line_count=$(echo "$line_count" | tr -dc '0-9')
: "${bash_blocks:=0}" "${bash_commands:=0}" "${phases:=0}" "${context_patterns:=0}" "${line_count:=0}"
# Score: higher = better candidate for script extraction
score=0
reasons=""
# Many bash blocks = repetitive commands that could be consolidated
if [ "$bash_blocks" -ge 5 ]; then
score=$((score + bash_blocks))
reasons="${reasons}bash_blocks($bash_blocks) "
fi
# Many individual commands = token-heavy execution
if [ "$bash_commands" -ge 8 ]; then
score=$((score + bash_commands / 2))
reasons="${reasons}commands($bash_commands) "
fi
# Multi-phase workflow = consolidation opportunity
if [ "$phases" -ge 3 ]; then
score=$((score + phases * 2))
reasons="${reasons}phases($phases) "
fi
# Context-gathering patterns = single-script opportunity
if [ "$context_patterns" -ge 4 ]; then
score=$((score + context_patterns))
reasons="${reasons}context_gathering($context_patterns) "
fi
# Large skill file = likely has extractable logic
if [ "$line_count" -ge 200 ]; then
score=$((score + 3))
reasons="${reasons}large(${line_count}L) "
fi
# Report if score is meaningful
if [ "$score" -ge 8 ]; then
candidates=$((candidates + 1))
# Determine script type recommendation
script_type="utility"
[ "$context_patterns" -ge 4 ] && script_type="context-gather"
[ "$phases" -ge 3 ] && script_type="workflow"
[ "$bash_commands" -ge 10 ] && script_type="multi-tool"
echo " CANDIDATE: $plugin_name/$skill_name"
echo " SCORE: $score"
echo " TYPE: $script_type"
echo " METRICS: ${line_count}L, ${bash_blocks} bash blocks, ${bash_commands} commands, ${phases} phases"
echo " REASONS: $reasons"
echo ""
fi
done
echo "--- SUMMARY ---"
echo "TOTAL_SKILLS=$total_skills"
echo "WITH_SCRIPTS=$with_scripts"
echo "CANDIDATES=$candidates"
echo ""
# Suggest script types
echo "--- SCRIPT TYPE GUIDE ---"
echo " context-gather: Consolidates multiple read-only commands into structured output"
echo " workflow: Replaces multi-phase process with single execution"
echo " multi-tool: Auto-detects tools/environment and runs appropriate commands"
echo " utility: General-purpose helper for repetitive operations"
echo ""
echo "=== ANALYSIS COMPLETE ==="
#!/usr/bin/env bash
# Project Discovery Script
# Consolidates the 5-phase discovery workflow into a single execution.
# Outputs structured text that Claude can parse efficiently.
# Usage: bash discover.sh [directory]
#
# Replaces ~20 individual tool calls with one script execution,
# saving tokens and providing consistent output format.
set -euo pipefail
TARGET_DIR="${1:-.}"
cd "$TARGET_DIR" || exit 1
# Phase 1: Git State Analysis
echo "=== PHASE 1: GIT STATE ==="
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "NOT_A_GIT_REPO=true"
echo "=== END PHASE 1 ==="
echo ""
echo "=== DISCOVERY COMPLETE ==="
exit 0
fi
current_branch=$(git branch --show-current 2>/dev/null || echo "DETACHED")
echo "BRANCH=$current_branch"
git_status=$(git status --porcelain 2>/dev/null)
staged_count=$(echo "$git_status" | grep -c "^[MADRC]" 2>/dev/null || echo "0")
unstaged_count=$(echo "$git_status" | grep -c "^.[MADRC?]" 2>/dev/null || echo "0")
untracked_count=$(echo "$git_status" | grep -c "^??" 2>/dev/null || echo "0")
echo "STAGED=$staged_count"
echo "UNSTAGED=$unstaged_count"
echo "UNTRACKED=$untracked_count"
echo "CLEAN=$([ -z "$git_status" ] && echo "true" || echo "false")"
# Remote sync
if git rev-parse --verify "@{u}" >/dev/null 2>&1; then
ahead=$(git rev-list --count "@{u}..HEAD" 2>/dev/null || echo "0")
behind=$(git rev-list --count "HEAD..@{u}" 2>/dev/null || echo "0")
echo "AHEAD=$ahead"
echo "BEHIND=$behind"
else
echo "NO_UPSTREAM=true"
fi
# Recent commits
echo "RECENT_COMMITS:"
git log --oneline --decorate -n 5 2>/dev/null | sed 's/^/ /'
# Conventional commits detection
conv_count=$(git log --oneline -n 20 2>/dev/null | grep -cE "^[a-f0-9]+ (feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(.+\))?:" || echo "0")
echo "CONVENTIONAL_COMMITS=$conv_count/20"
# Last commit info
last_commit=$(git log -1 --format='%H|%s|%an|%ar' 2>/dev/null || echo "")
echo "LAST_COMMIT=$last_commit"
# Risk flags
echo "RISK_FLAGS:"
[ "$current_branch" = "main" ] || [ "$current_branch" = "master" ] && [ -n "$git_status" ] && echo " - ON_MAIN_WITH_CHANGES"
[ "$current_branch" = "DETACHED" ] && echo " - DETACHED_HEAD"
[ "${behind:-0}" -gt 0 ] && echo " - BEHIND_REMOTE_BY_${behind}"
[ -n "$git_status" ] && echo " - UNCOMMITTED_CHANGES"
echo "=== END PHASE 1 ==="
echo ""
# Phase 2: Project Type Detection
echo "=== PHASE 2: PROJECT TYPE ==="
echo "MANIFESTS:"
for manifest in package.json Cargo.toml pyproject.toml go.mod Gemfile pom.xml build.gradle composer.json mix.exs deno.json bun.lockb; do
[ -f "$manifest" ] && echo " - $manifest"
done
# Detect monorepo
manifest_count=$(find . -maxdepth 3 \( -name "package.json" -o -name "Cargo.toml" -o -name "pyproject.toml" -o -name "go.mod" \) ! -path "*/node_modules/*" ! -path "*/.git/*" 2>/dev/null | wc -l)
echo "MANIFEST_COUNT=$manifest_count"
echo "MONOREPO=$([ "$manifest_count" -gt 2 ] && echo "likely" || echo "no")"
# Language detection
echo "LANGUAGES:"
[ -f "package.json" ] && echo " - javascript/typescript"
[ -f "Cargo.toml" ] && echo " - rust"
[ -f "pyproject.toml" ] || [ -f "setup.py" ] && echo " - python"
[ -f "go.mod" ] && echo " - go"
[ -f "Gemfile" ] && echo " - ruby"
[ -f "pom.xml" ] || [ -f "build.gradle" ] && echo " - java"
[ -f "composer.json" ] && echo " - php"
[ -f "mix.exs" ] && echo " - elixir"
# Framework detection
echo "FRAMEWORKS:"
if [ -f "package.json" ]; then
for fw in react vue next nuxt svelte angular express fastify nest remix astro; do
grep -q "\"$fw\"" package.json 2>/dev/null && echo " - $fw"
done
fi
if [ -f "pyproject.toml" ]; then
for fw in django fastapi flask pyramid; do
grep -qi "$fw" pyproject.toml 2>/dev/null && echo " - $fw"
done
fi
# Directory structure
echo "TOP_DIRS:"
find . -maxdepth 1 -type d ! -name '.' -print 2>/dev/null | sed 's|^\./||' | sort | head -15 | sed 's/^/ - /'
echo "=== END PHASE 2 ==="
echo ""
# Phase 3: Development Tooling
echo "=== PHASE 3: TOOLING ==="
# Package scripts
if [ -f "package.json" ]; then
echo "NPM_SCRIPTS:"
jq -r '.scripts | keys[]' package.json 2>/dev/null | head -20 | sed 's/^/ - /' || true
fi
# Makefile targets
if [ -f "Makefile" ]; then
echo "MAKE_TARGETS:"
grep -E "^[a-zA-Z0-9_-]+:" Makefile 2>/dev/null | cut -d: -f1 | head -15 | sed 's/^/ - /'
fi
# Justfile targets
if [ -f "Justfile" ] || [ -f "justfile" ]; then
echo "JUST_TARGETS:"
just --list --unsorted 2>/dev/null | tail -n +2 | head -15 | sed 's/^/ - /' || grep -E "^[a-zA-Z0-9_-]+:" [Jj]ustfile 2>/dev/null | cut -d: -f1 | head -15 | sed 's/^/ - /'
fi
# Linters/formatters
echo "CODE_QUALITY:"
for tool in .eslintrc .eslintrc.js .eslintrc.json eslint.config.js eslint.config.mjs biome.json biome.jsonc .prettierrc .prettierrc.json prettier.config.js ruff.toml .ruff.toml rustfmt.toml .golangci.yml .golangci.yaml; do
[ -f "$tool" ] && echo " - $tool"
done
[ -f "pyproject.toml" ] && grep -q "\[tool.ruff\]" pyproject.toml 2>/dev/null && echo " - ruff (in pyproject.toml)"
[ -f "pyproject.toml" ] && grep -q "\[tool.black\]" pyproject.toml 2>/dev/null && echo " - black (in pyproject.toml)"
# Test frameworks
echo "TEST_CONFIG:"
for cfg in vitest.config.ts vitest.config.js jest.config.ts jest.config.js pytest.ini conftest.py .pytest.ini setup.cfg playwright.config.ts cypress.config.ts; do
[ -f "$cfg" ] && echo " - $cfg"
done
[ -f "pyproject.toml" ] && grep -q "\[tool.pytest" pyproject.toml 2>/dev/null && echo " - pytest (in pyproject.toml)"
# Pre-commit
echo "PRE_COMMIT:"
if [ -f ".pre-commit-config.yaml" ]; then
echo " CONFIGURED=true"
grep -E "^\s+- id:" .pre-commit-config.yaml 2>/dev/null | sed 's/.*- id:/ -/' | head -10
else
echo " CONFIGURED=false"
fi
# CI/CD
echo "CI_CD:"
if [ -d ".github/workflows" ]; then
find .github/workflows -maxdepth 1 \( -name '*.yml' -o -name '*.yaml' \) -exec basename {} \; 2>/dev/null | sed 's/^/ - github: /'
fi
[ -f ".gitlab-ci.yml" ] && echo " - gitlab-ci"
[ -f ".circleci/config.yml" ] && echo " - circleci"
[ -f "Jenkinsfile" ] && echo " - jenkins"
echo "=== END PHASE 3 ==="
echo ""
# Phase 4: Documentation
echo "=== PHASE 4: DOCUMENTATION ==="
echo "DOC_FILES:"
for doc in README.md README.rst README.txt CONTRIBUTING.md CHANGELOG.md LICENSE LICENSE.md ARCHITECTURE.md SECURITY.md; do
[ -f "$doc" ] && echo " - $doc"
done
[ -d "docs" ] && echo " - docs/ ($(find docs -type f 2>/dev/null | wc -l) files)"
# README summary (first meaningful line)
if [ -f "README.md" ]; then
echo "README_TITLE: $(head -5 README.md | grep -m1 "^#" | sed 's/^#* //')"
echo "README_LINES: $(wc -l < README.md)"
fi
echo "=== END PHASE 4 ==="
echo ""
# Phase 5: Summary
echo "=== PHASE 5: SUMMARY ==="
# Determine risk level
risk_level="SAFE"
[ -n "$git_status" ] && risk_level="WARNING"
[ "$current_branch" = "main" ] || [ "$current_branch" = "master" ] && [ -n "$git_status" ] && risk_level="CRITICAL"
[ "$current_branch" = "DETACHED" ] && risk_level="CRITICAL"
echo "RISK_LEVEL=$risk_level"
echo "=== DISCOVERY COMPLETE ==="