code996

repository·main·Indexed 24 days ago

https://github.com/hellodigua/code996

A Git analysis tool (v1.4.0) that calculates coding intensity and overtime patterns by analyzing commit time distributions. It identifies '996' culture and team work patterns through visual reports, supporting single and multi-repository modes. The tool performs all analysis locally and provides output in text, JSON, Markdown, and Web formats.

Tokens
20.6K
Snippets
29
Records
117
Agent score
81%

What's inside code996

  1. Project Roadmap and Future Features

    main

    The development roadmap for code996 focuses on Work-Life Balance (WLB) and identifying 'work pits' (unhealthy work environments). Planned features include:

    • Refined overtime ratio analysis: More granular metrics for measuring overtime.
    • Shit-mountain index (Complexity analysis): Analyzing code complexity to identify high-maintenance codebases, which is often a driver of excessive overtime.
  2. Analyze team work intensity with code996

    main

    The code996 tool analyzes Git repositories to generate reports on team work intensity, overtime patterns, and the '996' index (working 9 AM to 9 PM, 6 days a week). It uses semantic analysis of git log data and can incorporate user-provided team context (like team size or flexible work policies) to produce a narrative report for managers or teams.

    Key Capabilities:

    • Detect Git repositories in the current or specified directories.
    • Analyze work-hour distributions (24-hour and weekday patterns).
    • Identify overtime trends (late nights, weekends, and peak overtime days).
    • Compare work intensity across multiple repositories.
    • Generate structured JSON data for programmatic use.
  3. Understanding code996's analysis accuracy with Squash commits

    main
    If a project uses a workflow where multiple local commits are squashed before being pushed, it may impact the granularity of the data. However, code996 relies on statistical patterns. Once the sample size of commits reaches a sufficient number, the tool identifies the team's collective work pattern, treating individual squash habits as statistical 'noise'.
  4. Structure of the Team Work Intensity Analysis Report

    main

    The code996 project generates a structured analysis report titled "团队工作强度分析报告" (Team Work Intensity Analysis Report). The report is composed of several key sections that provide a qualitative and quantitative assessment of a team's working patterns based on git commit data.

    Report Sections

    1. Overview & Core Conclusions (概览与核心结论): Provides a qualitative summary (e.g., "The team is in a heavy overtime state") and key metrics including the index996 score, rating, overTimeRatio, totalCommits, and inferred working hours (startHour and endHour).
    2. Work Time Distribution (工作时间分布): Analyzes hourlyDistribution (peak commit times) and weekdayDistribution (weekday vs. weekend activity).
    3. Overtime Analysis (加班分析):
      • Weekday Overtime: Identifies peak overtime days using weekdayOvertime and peakDay (measured in commit counts).
      • Weekend Overtime: Tracks Saturday and Sunday overtime days, including a metric for "real overtime" (days where commits cover $\ge 3$ different hour slots).
      • Late Night Overtime: Measures midnightRate and counts days with late-night/dawn activity.
      • Overtime Content: Uses semantic analysis of git logs to categorize overtime tasks (e.g., Feature Development, Bug Fixing, Refactoring, CI/CD) with percentage distribution and examples.
    4. Contributor Activity Comparison (贡献者活动对比): A breakdown of activity per contributor (team.contributors[]), showing their total commits, percentage of total activity, overtime commits, overtime ratio, and intensityLevel.
    5. Multi-Repository Aggregated View (多仓库聚合视图): If analyzing multiple repositories, this section provides a side-by-side comparison of the index996, overTimeRatio, and totalCommits for each repository.
    6. Risk Assessment & Improvement Suggestions (风险评估与改进建议): Provides qualitative risk assessments and actionable suggestions based on the data and user-provided context.
  5. How code996 analysis modes work

    main

    code996 automatically detects the environment to choose the most appropriate analysis mode:

    • Single Repository Mode: Triggered when running code996 inside a Git repository or pointing to a single repository path.
    • Multi-Repository Mode: Triggered when the command is run in a directory containing multiple repositories, or when multiple paths are provided as arguments. This mode allows for one-click scanning and comparison of multiple repositories.

    Examples:

    code996                    # Single repo (current)
    code996 /path/to/repo      # Single repo (specified)
    code996 /proj1 /proj2      # Multi-repo mode
    code996 /workspace         # Scans all sub-repositories in /workspace
    code996 /proj1 /proj2
  6. Core algorithms and features

    main

    The tool uses several key algorithms to interpret Git logs:

    • Time Distribution Analysis: Collects commit times at a minute level and aggregates them into 48 half-hour points. While the default display is hourly (24 points), a half-hour mode (48 points) is available.
    • Work Time Identification: Estimates start times using the 10%-20% quantile of recent samples. Standard working hours are fixed at 9 hours. Evening activity end times are displayed separately and do not expand the standard working hours.
    • 996 Index Calculation: Constructs an index based on the ratio of overtime work and provides a Chinese description.
    • Project Type Identification: Automatically identifies if a project is a "Company Project" or an "Open Source Project" based on work regularity, weekend activity, and evening patterns.
    • Cross-timezone Collaboration Detection: Identifies cross-timezone projects by detecting timezone dispersion and the proportion of commits during "sleep periods" (threshold: non-dominant timezone > 1%).
    • Holiday/Compensatory Leave Recognition: If the primary timezone is +0800 and accounts for > 50% of activity, it automatically applies Chinese holiday/compensatory leave logic. For other timezones, this can be manually enabled using the --cn flag.
    • Uncertainty Handling: If work hour confidence is below 60%, the tool provides an index range for common work scenarios instead of a single definitive value.
  7. Determine time ranges for multi-repository analysis

    main

    When analyzing multiple repositories, it is best practice to use a shared time range to allow for meaningful comparison.

    1. Identify the shared end date (<shared-until>): Run the following command for each repository and take the latest date found:
      git -C "<path>" log --no-merges --format="%cd" --date=format:%Y-%m-%d --max-count=1
    2. Identify the shared start date (<shared-since>): Calculate this by going back 365 days from the <shared-until> date.
    3. Execute analysis: Pass both -s <shared-since> and -u <shared-until> to every code996 call in the set.
    git -C "<path>" log --no-merges --format="%cd" --date=format:%Y-%m-%d --max-count=1
  8. Configure Chinese Holiday Mode for semantic analysis

    main

    When analyzing commit timestamps, you can enable or disable Chinese Holiday Mode to distinguish between workdays and rest days accurately.

    • Enabling Mode: Explicitly use the --cn flag. If not explicitly set, the system checks the holidayMode field in the JSON. If the field is missing, it auto-enables if $\ge 50%$ of commits show a +08:00 timezone offset.
    • Behavior without Holiday Mode: Monday–Friday are workdays; Saturday–Sunday are rest days.
    • Behavior with Holiday Mode: Uses a reliable holiday-calendar to distinguish between public_holiday and transfer_workday.

    Note: If a reliable calendar cannot be obtained, the system will fallback to analyzing 23:00–05:59 samples only, skipping weekday evening and weekend daytime attribution, and will note this limitation in the report.

  9. How code996 works

    main

    The tool performs local analysis of Git commit data to estimate work patterns and a '996 Index'.

    Data Collection Flow: Git Repo $\rightarrow$ git log collection $\rightarrow$ Daily first commit + Hourly distribution $\rightarrow$ Percentile estimation of start/end work $\rightarrow$ 996 Index calculation $\rightarrow$ Result output.

    Key Concepts:

    • Work Time Identification: Uses the 10%-20% percentile of recent daily-first-commit samples to estimate start times.
    • 996 Index: A calculated value based on the overtime ratio.
    • Project Type Identification: Automatically identifies if a project is "corporate" or "open source" based on work regularity and weekend/evening activity.
    • Privacy: All analysis is performed locally; no data is uploaded unless you explicitly run the benchmark command.
  10. Run Benchmark for Algorithm Calibration

    main

    If you wish to help calibrate the code996 algorithms, you can run a local benchmark. This command analyzes the repository locally and generates an unlabeled code996-benchmark-*.json file. You can then review this file before sending it to the maintainer.

    To provide more useful context for a labeled sample, use the following flags:

    • --reference-hours: The team's actual or typical standard hours.
    • --team-size: Used to study algorithm behavior by team-size segment.
    • --schedule: Optional schedule context.
    • --label-confidence: Optional confidence context.
    • -y / --since / --until: Use a fixed range for reproducible datasets.
    # Basic benchmark
    npx code996 benchmark
    
    # Labeled benchmark with context
    npx code996 benchmark \
      --reference-hours 9.5-18.5 \
      --team-size 20
  11. Generate a code996 analysis report

    main

    The final report integrates quantitative data (from the code996 JSON) and qualitative data (from semantic commit analysis).

    Report Components

    • Quantitative Data: All metrics from the code996 JSON.
    • Qualitative Data: Semantic classification of overtime work.
    • Contributor Analysis: Analyzes if overtime is concentrated among specific contributors using team.contributors[].
      • Note: Different emails are treated as different identities.
      • Note: Bots, release servers, and CI accounts should be labeled separately and not included in personal risk conclusions.
    • Multi-Repo View: For multiple repositories, the report shows a horizontal comparison of each repo's core.index996.
      • Weighted Average: If a total overtime ratio is needed, use: sum(core.totalCommits × core.overTimeRatio) / sum(core.totalCommits) (labeled as an estimate).

    Output Formats

    Unless specified otherwise, the report defaults to being displayed in the chat. Supported formats include:

    • Direct Display: Full report in the chat interface.
    • Markdown: Saved as ./code996-report-<YYYY-MM-DD>.md.
    • HTML: A self-contained HTML file ./code996-report-<YYYY-MM-DD>.html with inline CSS (white background, system fonts, max-width 800px).
  12. Quick Start with code996

    main

    code996 is an analysis tool that statistics Git project commit time distribution to deduce coding work intensity and identify overtime culture. It requires Node.js 18 or newer.

    Run without installation

    You can run the tool immediately using npx in the current repository or a parent directory of repositories:

    npx -y code996

    Run with global installation

    To avoid re-downloading the tool every time, install it globally:

    npm i -g code996
    code996

    Viewing Reports

    By default, the tool prints a text report to the terminal and saves a visual bilingual report in Downloads/code996-report/[timestamp]_[project_name]/.

    To automatically open the generated visual report in your browser, use the --open flag:

    npx code996 --open
    # Run in current repo or parent directory of repos
    npx -y code996