agentleFS
goplusgoplus/xgo/CLAUDE.md

xgo

CLAUDE.md9.5k starsChanged 4 months agoApache-2.0View on GitHub

When implementing new language syntax, follow this three-phase approach: IMPORTANT: Each phase must be implemented in a separate pull request. Do NOT mix phases in a single PR. This separation ensures: - Clear review focus (grammar vs semantics vs documentation) - Easier rollback if issues are found - Better git history and maintainability - Allows grammar to be reviewed independently from implementation details When submitting a new PR to the gogen repository for a change, also submit a PR to…

We split this CLAUDE.md into the rules it gives an agent

19 rules. About 0 are common, 13 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When implementing new language syntax, follow this three-phase approach:

    line 7
  2. Very specific:

    Printer: Add formatting support for new syntax (inverse of parsing) in printer/ directory

    line 19
  3. Very specific:

    Testing: Add test cases in parser/_testdata/ for new syntax and focused unit tests for affected AST consumers

    line 21
  4. Very specific:

    What NOT to include: Do NOT add any code generation or semantic logic in cl/ package - that belongs in Phase 2

    line 23
  5. Very specific:

    Testing: Add comprehensive test cases in cl/_testxgo/ covering various usage scenarios

    line 29
  6. Very specific:

    Quick Start Guide: Add feature documentation to doc/docs.md with practical examples

    line 36
  7. Distinctive:

    Table of Contents: Update TOC in quick start to include new feature section

    line 37
  8. Distinctive:

    Language Specification: Update specification documents (see Language Specification Structure below)

    line 38
  9. Distinctive:

    When I request syntax additions, first confirm the exact grammar specification

    line 43
  10. Distinctive:

    Always consider backward compatibility with existing Go code

    line 44
  11. Distinctive:

    Ensure new syntax doesn't break existing XGo/Go code

    line 62
  12. Distinctive:

    Follow Go idioms in generated code

    line 63
  13. Very specific:

    Code Formatting: Run go fmt on any changed source files before committing

    line 65
  14. Distinctive:

    Update language specification documents

    line 69
  15. Distinctive:

    Add examples to Quick Start guide

    line 70
  16. Distinctive:

    Document any limitations or special considerations

    line 71
  17. Distinctive:

    Ensure all code examples in documentation are runnable and correct

    line 81
  18. Distinctive:

    Verify documentation accurately reflects implemented behavior

    line 82
  19. Distinctive:

    Check that TOC links work correctly

    line 83

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

XGo Project AI Assistant Guide

Workflow

Adding New Syntax Features

When implementing new language syntax, follow this three-phase approach:

IMPORTANT: Each phase must be implemented in a separate pull request. Do NOT mix phases in a single PR. This separation ensures:

  • Clear review focus (grammar vs semantics vs documentation)
  • Easier rollback if issues are found
  • Better git history and maintainability
  • Allows grammar to be reviewed independently from implementation details

Phase 1: Grammar Definition (First Pull Request)

Scope: AST, parser, printer, and required AST consumer modifications ONLY

  • AST: Define new node types in ast/ directory (if needed - often existing nodes can be reused)
  • Parser: Implement parsing rules in parser/ directory to recognize the new syntax
  • Printer: Add formatting support for new syntax (inverse of parsing) in printer/ directory
  • AST Consumers: Audit manually maintained consumers such as ast.Walk, ast/filter.go, parser expression validation, and x/format
  • Testing: Add test cases in parser/_testdata/ for new syntax and focused unit tests for affected AST consumers
    • Note: Printer reuses parser test cases and also has printer-specific cases in printer/_testdata/
  • What NOT to include: Do NOT add any code generation or semantic logic in cl/ package - that belongs in Phase 2

Phase 2: Semantic Implementation (Second Pull Request)

Scope: Code generation via cl package and gogen module ONLY

  • Code Generation: Implement semantics using github.com/goplus/gogen package
  • Type Safety: Leverage gogen's type information maintenance for semantic correctness
  • Testing: Add comprehensive test cases in cl/_testxgo/ covering various usage scenarios
  • Prerequisite: Phase 1 PR must be merged before starting Phase 2

When submitting a new PR to the gogen repository for a change, also submit a PR to the xgo repository that updates the gogen module to the latest code from the corresponding gogen branch. The xgo PR's go.mod/go.sum must pin the gogen dependency to the feature branch's commit (not to a released version), so the two PRs represent a coherent, reviewable change set.

Phase 3: Documentation (Third Pull Request)

Scope: User-facing documentation updates ONLY

  • Quick Start Guide: Add feature documentation to doc/docs.md with practical examples
  • Table of Contents: Update TOC in quick start to include new feature section
  • Language Specification: Update specification documents (see Language Specification Structure below)
  • Examples: Provide clear, runnable code examples demonstrating the feature
  • Prerequisite: Phase 2 PR must be merged before starting Phase 3

Communication Protocol

  • When I request syntax additions, first confirm the exact grammar specification
  • Always consider backward compatibility with existing Go code
  • For ambiguous requirements, ask clarifying questions about:
    • Precedence and associativity rules
    • Error handling expectations
    • Integration with existing type system

Technical Specifications

Compiler Architecture

  • Target: XGo compiles to Go code, not machine code
  • Foundation: Built on github.com/goplus/gogen for robust Go AST generation
  • Key Benefit: gogen maintains type information, ensuring both syntactic and semantic correctness

Quality Standards

Code Requirements

  • Maintain full compatibility with existing Go ecosystem
  • Ensure new syntax doesn't break existing XGo/Go code
  • Follow Go idioms in generated code
  • Provide comprehensive error messages
  • Code Formatting: Run go fmt on any changed source files before committing

Documentation Expectations

  • Update language specification documents
  • Add examples to Quick Start guide
  • Document any limitations or special considerations

Testing Requirements

  • Phase 1: 100% test coverage for new syntax parsing in parser/_testdata/ and focused tests for affected AST consumers
  • Phase 2: Comprehensive test coverage for semantic implementation in cl/_testxgo/ covering:
    • Common usage scenarios
    • Edge cases and error conditions
    • Integration with existing type system
  • Phase 3: Documentation validation
    • Ensure all code examples in documentation are runnable and correct
    • Verify documentation accurately reflects implemented behavior
    • Check that TOC links work correctly
  • Coverage rule: Unit test coverage must not decrease across any PR. Run go test ./... -cover before and after your changes and compare. If coverage drops for any package, add tests to compensate before submitting.

Download now (ZIP)

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 1 mentionFeb 2026: 4 mentionsMar 2026: 4 mentionsApr 2026: 5 mentionsMay 2026: 1 mentionJun 2026: 5 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 2 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the goplus/xgo repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about goplus/xgo

The biggest 5 of 27 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 27

Talked about on GitHub, Hacker News, Bluesky and the web (27 times).

On GitHub · 24

19 more on GitHub

On Hacker News · 1

On the web · 1

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.