# scan > Project-wide text analysis and issue detection for code comments, documentation, variable names, and error messages - Author: Nash Gao - Repository: nashgao/mqtt-client - Version: 20260210001543 - Stars: 3 - Forks: 1 - Last Updated: 2026-02-09 - Source: https://github.com/nashgao/mqtt-client - Web: https://mule.run/skillshub/@@nashgao/mqtt-client~scan:20260210001543 --- --- allowed-tools: all description: Project-wide text analysis and issue detection for code comments, documentation, variable names, and error messages --- # 🔍🔍🔍 CRITICAL REQUIREMENT: COMPREHENSIVE TEXT ANALYSIS! **THIS IS NOT A MODIFICATION TASK - THIS IS A COMPREHENSIVE TEXT ANALYSIS TASK!** When you run `/code/scan`, you are REQUIRED to: 1. **ANALYZE** all text content in codebase (comments, docs, strings, identifiers) 2. **DETECT** grammar, spelling, clarity, and consistency issues 3. **CATEGORIZE** issues by severity and impact on code functionality 4. **GENERATE** comprehensive report with actionable insights 5. **USE MULTIPLE AGENTS** for thorough analysis: - Spawn one agent to scan code comments and documentation - Spawn another to analyze variable and function names - Spawn more agents for different text content types - Say: "I'll spawn multiple analysis agents to scan text comprehensively" **FORBIDDEN BEHAVIORS:** - ❌ "Surface-level text scanning" → NO! Deep analysis required! - ❌ "Ignoring code context" → NO! Context-aware text analysis! - ❌ "Missing text in string literals" → NO! Scan all text content! - ❌ "Generic issue reporting" → NO! Specific, actionable findings! **MANDATORY WORKFLOW:** ``` 1. Text content discovery → Find all text in codebase 2. IMMEDIATELY spawn analysis agents for parallel processing 3. Issue detection → Identify grammar, spelling, clarity problems 4. Severity classification → Categorize by impact and urgency 5. Report generation → Create comprehensive analysis report 6. VERIFY completeness → Ensure all text content analyzed ``` **YOU ARE NOT DONE UNTIL:** - ✅ All text content in codebase has been analyzed - ✅ Issues categorized by type and severity level - ✅ Comprehensive report generated with actionable insights - ✅ Zero text content missed or overlooked - ✅ Context-aware analysis completed for all findings --- 🛑 **MANDATORY TEXT ANALYSIS PROTOCOL** 🛑 1. Re-read ~/.claude/CLAUDE.md RIGHT NOW 2. Check current TODO.md status 3. Verify you're performing analysis, not modification 4. Deploy multiple agents for comprehensive coverage Execute comprehensive text analysis with ZERO tolerance for incomplete scanning. **FORBIDDEN SHORTCUT PATTERNS:** - "This text looks fine" → NO, analyze systematically - "Comments aren't that important" → NO, all text matters - "Variable names are functional" → NO, check clarity too - "Only scan obvious files" → NO, comprehensive coverage required - "Quick scan is sufficient" → NO, thorough analysis needed You are analyzing text in: $ARGUMENTS Let me ultrathink about comprehensive text analysis strategy and multi-agent deployment. 🚨 **REMEMBER: Thorough analysis prevents quality issues!** 🚨 **Comprehensive Text Analysis Protocol:** ## Step 0: Text Content Discovery and Classification **Discover All Text Content Types:** ```bash #!/bin/bash # Source shared utilities SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/../../shared/code/utils.md" source "$SCRIPT_DIR/../../shared/code/safety.md" # Text content discovery function discover_text_content() { local target_dir=${1:-.} local discovery_file="/tmp/text-discovery-$$" echo "=== TEXT CONTENT DISCOVERY ===" echo "Target: $target_dir" echo "Discovery file: $discovery_file" # Initialize discovery log cat > "$discovery_file" <> "$discovery_file" ;; "documentation") doc_files=$((doc_files + 1)) echo "DOCUMENTATION: $file" >> "$discovery_file" ;; "configuration") config_files=$((config_files + 1)) echo "CONFIGURATION: $file" >> "$discovery_file" ;; esac done # Log summary cat >> "$discovery_file" < "/tmp/text-analysis-agents-$$" < "$comment_report" <> "$comment_report" cat "${issues%:*}" >> "$comment_report" fi # Check for unclear or unhelpful comments if echo "$comment_text" | grep -q -E "\b(TODO|FIXME|XXX|HACK)\b"; then echo "ACTION_NEEDED: $file - $comment_text" >> "$comment_report" fi done rm -f "$text_file" fi done echo "📝 Comment Analysis Agent: Completed scanning" echo "$comment_report" } # Variable and Function Name Analysis Agent spawn_identifier_analysis_agent() { local target_dir=$1 local session_id=$2 echo "🏷️ Identifier Analysis Agent: Starting identifier clarity analysis..." local identifier_report="/tmp/identifier-analysis-$session_id" cat > "$identifier_report" <> "$identifier_report" fi # Too long identifiers if [ "$length" -gt 50 ]; then echo "UNCLEAR_LONG: $file - $identifier (too long: $length chars)" >> "$identifier_report" fi # Check for unclear abbreviations if echo "$identifier" | grep -q -E "[bcdfghjklmnpqrstvwxz]{3,}"; then echo "UNCLEAR_ABBREV: $file - $identifier (difficult abbreviation)" >> "$identifier_report" fi # Check for spelling in identifiers local words=$(echo "$identifier" | sed 's/[A-Z]/ &/g' | sed 's/_/ /g' | tr '[:upper:]' '[:lower:]') for word in $words; do if [ ${#word} -gt 3 ] && ! grep -q "^$word$" /usr/share/dict/words 2>/dev/null; then echo "SPELLING_SUSPECT: $file - $identifier (word: $word)" >> "$identifier_report" fi done done fi done echo "🏷️ Identifier Analysis Agent: Completed scanning" echo "$identifier_report" } # String Literals and Error Message Analysis Agent spawn_string_analysis_agent() { local target_dir=$1 local session_id=$2 echo "💬 String Analysis Agent: Starting string literal analysis..." local string_report="/tmp/string-analysis-$session_id" cat > "$string_report" <> "$string_report" cat "${quality_result%:*}" >> "$string_report" fi # Check for technical jargon in user messages if echo "$message_text" | grep -q -E "\b(null|undefined|NaN|bool|int|str|obj)\b"; then echo "TECHNICAL_JARGON: $file - $message_text" >> "$string_report" fi # Check for missing capitalization in error messages if echo "$message_text" | grep -q -E "^[a-z]"; then echo "CAPITALIZATION: $file - $message_text (should start with capital)" >> "$string_report" fi done < "$messages_file" rm -f "$messages_file" fi done echo "💬 String Analysis Agent: Completed scanning" echo "$string_report" } ``` ## Step 2: Comprehensive Issue Detection and Analysis **Text Quality Issue Detection:** ```bash # Comprehensive text quality scanning perform_comprehensive_text_scan() { local target_dir=${1:-.} local scan_session="scan-$$" echo "=== COMPREHENSIVE TEXT QUALITY SCAN ===" echo "Target: $target_dir" echo "Session: $scan_session" # Run text safety checks if ! run_text_safety_checks "scan" "$target_dir"; then echo "ERROR: Text safety checks failed" return 1 fi # Discover all text content local discovery_file=$(discover_text_content "$target_dir") # Deploy analysis agents deploy_text_analysis_agents "$target_dir" "$discovery_file" # Wait for all agents to complete wait_for_analysis_completion "$scan_session" # Aggregate analysis results aggregate_analysis_results "$scan_session" "$target_dir" # Generate comprehensive report generate_text_scan_report "$scan_session" "$target_dir" echo "✅ Comprehensive text scan completed" } # Wait for all analysis agents to complete wait_for_analysis_completion() { local session_id=$1 local agent_file="/tmp/text-analysis-agents-$$" echo "Waiting for analysis agents to complete..." if [ -f "$agent_file" ]; then # Wait for all agent processes local comment_pid=$(grep "comment_agent:" "$agent_file" | cut -d' ' -f2) local identifier_pid=$(grep "identifier_agent:" "$agent_file" | cut -d' ' -f2) local string_pid=$(grep "string_agent:" "$agent_file" | cut -d' ' -f2) local doc_pid=$(grep "documentation_agent:" "$agent_file" | cut -d' ' -f2) local config_pid=$(grep "config_agent:" "$agent_file" | cut -d' ' -f2) wait $comment_pid $identifier_pid $string_pid $doc_pid $config_pid echo "✅ All analysis agents completed" fi } # Aggregate analysis results from all agents aggregate_analysis_results() { local session_id=$1 local target_dir=$2 local aggregated_report="/tmp/aggregated-analysis-$session_id" echo "Aggregating analysis results..." cat > "$aggregated_report" <> "$aggregated_report" cat "$report_file" >> "$aggregated_report" echo "" >> "$aggregated_report" fi done echo "Results aggregated: $aggregated_report" echo "$aggregated_report" } ``` ## Step 3: Issue Severity Classification and Prioritization **Classify Issues by Impact and Urgency:** ```bash # Classify and prioritize text quality issues classify_text_issues() { local aggregated_report=$1 local classified_report="/tmp/classified-issues-$$" echo "Classifying text quality issues by severity..." # Initialize classification report cat > "$classified_report" <> "$classified_report" || true cat >> "$classified_report" <> "$classified_report" || true cat >> "$classified_report" <> "$classified_report" || true cat >> "$classified_report" <> "$classified_report" || true echo "Issue classification completed: $classified_report" echo "$classified_report" } # Generate issue statistics and metrics generate_issue_statistics() { local classified_report=$1 local stats_file="/tmp/issue-stats-$$" echo "Generating text quality statistics..." local critical_count=$(grep -c "CRITICAL ISSUES" -A 1000 "$classified_report" | grep -c -E "(SYNTAX_ERROR|BROKEN_LINK|SECURITY_SENSITIVE|USER_MESSAGE_ISSUE)" || echo "0") local high_count=$(grep -c -E "(UNCLEAR_|GRAMMAR|SPELLING|CAPITALIZATION|TECHNICAL_JARGON)" "$classified_report" || echo "0") local medium_count=$(grep -c -E "(INCONSISTENT|STYLE|READABILITY|ACTION_NEEDED)" "$classified_report" || echo "0") local low_count=$(grep -c -E "(MINOR|SUGGESTION|ENHANCEMENT)" "$classified_report" || echo "0") local total_issues=$((critical_count + high_count + medium_count + low_count)) cat > "$stats_file" </dev/null || echo "0.0")% - High: $(echo "scale=1; $high_count * 100 / $total_issues" | bc 2>/dev/null || echo "0.0")% - Medium: $(echo "scale=1; $medium_count * 100 / $total_issues" | bc 2>/dev/null || echo "0.0")% - Low: $(echo "scale=1; $low_count * 100 / $total_issues" | bc 2>/dev/null || echo "0.0")% Recommended Action: EOF if [ "$critical_count" -gt 0 ]; then echo "IMMEDIATE: Address $critical_count critical issues first" >> "$stats_file" elif [ "$high_count" -gt 10 ]; then echo "URGENT: High volume of high-priority issues ($high_count)" >> "$stats_file" elif [ "$total_issues" -gt 50 ]; then echo "PLANNED: Schedule text quality improvement session" >> "$stats_file" else echo "MAINTENANCE: Regular text quality is good" >> "$stats_file" fi echo "$stats_file" } ``` ## Step 4: Comprehensive Report Generation **Generate Actionable Text Quality Report:** ```bash # Generate comprehensive text scan report generate_text_scan_report() { local session_id=$1 local target_dir=$2 local report_file="$target_dir/text-quality-scan-report.md" echo "Generating comprehensive text quality scan report..." # Get aggregated results and classification local aggregated_report="/tmp/aggregated-analysis-$session_id" local classified_report=$(classify_text_issues "$aggregated_report") local stats_file=$(generate_issue_statistics "$classified_report") # Generate markdown report cat > "$report_file" <