This is a template repository that provides a foundation for GitHub Action-based agents. It includes a modular system for dynamic documentation generation and other reusable components that make it easier to build and maintain agent-driven workflows.
- Modular documentation system with Jinja2 templates
- Automatic project structure documentation
- Reusable GitHub Actions workflows
- Centralized configuration management
- Utility functions for common operations
- Clean, maintainable architecture optimized for AI agents
- Built-in test framework with pytest
- Automated workflow dependencies
- Git operations handled through utilities
-
Workflow Permissions
- Go to Repository Settings → Actions → General → Workflow permissions
- Enable "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests"
-
Branch Protection (Optional but recommended)
- Go to Repository Settings → Branches → Branch protection rules
- Add rule for your main branch (e.g.,
mainormaster) - Enable:
- "Require pull request reviews before merging"
- "Require status checks to pass before merging"
- Allow:
- "Allow specific actors to bypass required pull requests"
- Add "github-actions[bot]" to the bypass list
No additional secrets are required for basic functionality. The workflows use the default GITHUB_TOKEN which is automatically provided.
If you're setting up using GitHub CLI, you can run these commands:
# Enable workflows
gh repo edit --enable-actions
# Set workflow permissions
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
"/repos/OWNER/REPO/actions/permissions/workflow" \
-f default_workflow_permissions='write' \
-F can_approve_pull_request_reviews=true
# Enable Issues (recommended for tracking)
gh repo edit --enable-issuesReplace OWNER/REPO with your repository details.
-
Workflow Permission Errors
- Error: "Resource not accessible by integration"
- Solution: Ensure workflow permissions are set to "Read and write"
-
Git Push Failures
- Error: "GitHub Actions is not permitted to create or approve pull requests"
- Solution: Check "Allow GitHub Actions to create and approve pull requests"
-
Workflow Trigger Issues
- Error: Workflows not triggering each other
- Solution: Ensure
GITHUB_TOKENhas sufficient permissions and "Read and write permissions" is enabled
This project is designed to be used as a template repository. To get started:
- Click "Use this template" on GitHub
- Clone your new repository
- Install the development dependencies:
pip install -e ".[test]"
The README is automatically generated from templates in docs/readme/. The system works as follows:
- Base template (
docs/readme/base.md.j2) defines the overall structure - Individual sections are stored in
docs/readme/sections/as separate templates - Configuration is centralized in
pyproject.toml - GitHub Actions automatically rebuild the README when:
- Templates are modified
- Project structure changes
- Configuration is updated
To manually trigger a README rebuild:
python -m readme_generator readmeThe repository includes automatic project structure documentation:
- Structure is updated on file changes
- Tree output is formatted as a template
- README is automatically rebuilt to include the new structure
To manually update the structure:
python -m readme_generator structureThe project uses pytest for testing. To run tests:
# Run all tests
pytest
# Run with coverage report
pytest --cov=readme_generator
# Run specific test file
pytest tests/test_tree_generator.pyTests are automatically run:
- On every push to main
- When workflows are triggered
- Before README updates
- Before structure updates
This project follows a modular design principle to make it easier for AI agents to work with the codebase:
- Each component is self-contained and focused
- Configuration is centralized in
pyproject.toml - Utilities are designed to be reusable across workflows
- Git operations are handled through utility functions
- All features are tested using pytest
To add new README sections:
- Create a new template in
docs/readme/sections/ - Include it in
docs/readme/base.md.j2 - Add any necessary configuration to
pyproject.toml - Add tests for new functionality
When developing this project (or using it as a template), keep in mind these guidelines for effective collaboration with Large Language Models:
-
Separation of Concerns
- Each package should have a single, clear responsibility
- New features should be separate packages when appropriate
- Avoid coupling between packages
- Use consistent patterns across packages, but implement independently
- Cross-cutting concerns should use shared conventions
-
File Length and Modularity
- Keep files short and focused on a single responsibility
- If you find yourself using comments like "... rest remains the same" or "... etc", the file is too long
- Files should be completely replaceable in a single LLM interaction
- Long files should be split into logical components
-
Dependencies
- All dependencies managed in
pyproject.toml - Optional dependencies grouped by feature:
[project.optional-dependencies] test = ["pytest", ...] site = ["markdown2", ...] all = ["pytest", "markdown2", ...] # Everything
- Use appropriate groups during development:
pip install -e ".[test]" # Just testing pip install -e ".[all]" # Everything
- All dependencies managed in
-
Testing Standards
- Every new feature needs tests
- Tests should be clear and focused
- Use pytest fixtures for common setups
- All workflows depend on tests passing
- Test files should follow same modularity principles
-
Why This Matters
- LLMs work best with clear, focused contexts
- Complete file contents are better than partial updates with ellipsis
- Tests provide clear examples of intended behavior
- Shorter files make it easier for LLMs to:
- Understand the complete context
- Suggest accurate modifications
- Maintain consistency
- Avoid potential errors from incomplete information
-
Real World Example Our own organization follows these principles:
src/ ├── readme_generator/ # Core README generation │ ├── generators/ │ └── utils.py └── site_generator/ # Demo site generation ├── generator.py └── __main__.py -
Best Practices
- Aim for files under 200 lines
- Each file should have a single, clear purpose
- Use directory structure to organize related components
- Prefer many small files over few large files
- Consider splitting when files require partial updates
- Write tests alongside new features
- Run tests locally before pushing
The project includes an automated summary generation system designed to help LLMs efficiently work with the codebase. This system generates both local directory summaries and project-wide summaries to provide focused, relevant context for different tasks.
Each directory in the project contains a SUMMARY file that concatenates all text files in that directory. This provides focused, local context when working on directory-specific tasks.
Special project-wide summaries are maintained in the SUMMARIES/ directory on the summaries branch:
READMEs.md: Concatenation of all README files in the projectREADME_SUBs.md: Same as above but excluding the root READMEPYTHON.md: Structured view of all Python code including:- Function and class signatures
- Type hints
- Docstrings
- Clear indication of class membership
These are available on any branch in their respective directories:
# Example: View summary for the readme_generator package
cat src/readme_generator/SUMMARYThese live exclusively on the summaries branch:
# Switch to summaries branch
git checkout summaries
# View available summaries
ls SUMMARIES/Directory summaries are useful when:
- Getting up to speed on a specific package
- Understanding local code context
- Planning modifications to a package
The SUMMARIES/ directory helps with:
- Understanding overall project structure
- Finding relevant code across packages
- Reviewing API signatures and documentation
- Planning cross-package changes
- Point LLMs to specific summaries based on the task
- Use directory summaries for focused work
- Use project-wide summaries for architectural decisions
- Combine different summaries as needed for context
- Summaries are automatically updated on every push to
main - The
summariesbranch is workflow-owned and force-pushed on updates - Summary generation is configured in
pyproject.tomlunder[tool.summary] - Don't modify summaries directly - they're automatically generated
-
Public Repository
- GitHub Pages is available out-of-the-box for public repositories
- For private repositories, a GitHub Enterprise plan is required
- If you plan to make your repository public later, you can still set up and test the site generation locally
-
Repository Settings
- Once your repository is public (or on an Enterprise plan):
- Go to Repository Settings → Pages
- Under "Build and deployment":
- Set Source to "GitHub Actions"
- Once your repository is public (or on an Enterprise plan):
-
Branch Setup
- Create a
gh-pagesbranch:git checkout --orphan gh-pages git reset --hard git commit --allow-empty -m "Initial gh-pages commit" git push origin gh-pages git checkout main # Return to main branch
- This branch is required for GitHub Pages deployment
- The deployment workflow will manage this branch automatically once created
- Create a
# Install with site generation dependencies
pip install -e ".[all]"The site generator can be used locally regardless of repository visibility:
# Generate site locally
python -m site_generator build
# Site will be generated in _site/ directory (git-ignored)
# View the generated site by opening _site/index.html in your browserWhen requirements are met (public repository or Enterprise plan), the site automatically rebuilds and deploys when:
- The README is updated through the
build-readmeworkflow - The deployment workflow is modified
- The workflow is manually triggered
your-repo/
├── _site/ # Generated directory (git-ignored)
│ └── index.html # Generated site
├── docs/
│ └── site/
│ └── template.html # Site template
└── src/
└── site_generator/ # Generator package
The site template is located in docs/site/template.html and can be customized with:
- Custom CSS styles
- Additional JavaScript
- Modified layout and structure
- Custom header/footer content
# Generate site with default settings
python -m site_generator build
# Specify custom output directory
python -m site_generator build --output_dir="custom_dir"The site generation can be tested locally even if GitHub Pages deployment isn't available:
# Run the test suite
pytest tests/test_site_generator.py-
"Resource not accessible by integration" Error
- Problem: Deployment fails with "Resource not accessible by integration" or "Create Pages site failed"
- Solution: Ensure you've:
- Created the
gh-pagesbranch (see Branch Setup section above) - Enabled GitHub Pages in repository settings
- Set source to "GitHub Actions" in Pages settings
- Enabled proper workflow permissions
- Created the
-
Deployment Not Starting
- Problem: Workflow runs but site doesn't deploy
- Solution: Verify that:
- Repository is public or on Enterprise plan
gh-pagesbranch exists- Workflow has correct permissions in repository settings
-
Empty Site Deployment
- Problem: Site deploys but shows no content
- Solution: Check that:
- Build step is generating content in
_sitedirectory upload-pages-artifactstep has correct path- Site generator is installed with all dependencies
- Build step is generating content in
For any persistent issues, check the workflow run logs for specific error messages and ensure all setup steps have been completed in order.
The repository is organized as follows:
ai-gha
├── .github
│ └── workflows
│ ├── README.md
│ ├── build-readme.yml
│ ├── deploy-gh-pages.yml
│ ├── generate-summaries.yml
│ ├── test.yml
│ └── update-structure.yml
├── .gitignore
├── LICENSE
├── README.md
├── docs
│ ├── README.md
│ ├── readme
│ │ ├── README.md
│ │ ├── base.md.j2
│ │ └── sections
│ │ ├── development.md.j2
│ │ ├── introduction.md.j2
│ │ ├── prerequisites.md.j2
│ │ ├── site.md.j2
│ │ ├── structure.md.j2
│ │ ├── summaries.md.j2
│ │ ├── todo.md.j2
│ │ └── usage.md.j2
│ └── site
│ ├── README.md
│ └── template.html
├── pyproject.toml
├── src
│ ├── README.md
│ ├── readme_generator
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── __main__.py
│ │ ├── generators
│ │ │ ├── README.md
│ │ │ ├── __init__.py
│ │ │ ├── readme_generator.py
│ │ │ ├── structure_generator.py
│ │ │ └── tree_generator.py
│ │ └── utils.py
│ ├── site_generator
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── __main__.py
│ │ └── generator.py
│ └── summary_generator
│ ├── README.md
│ ├── __init__.py
│ ├── __main__.py
│ ├── generator.py
│ ├── signature_extractor.py
│ └── special_summaries.py
└── tests
├── conftest.py
├── test_generators.py
├── test_site_generator.py
├── test_summary_generator.py
└── test_tree_generator.py
-
.github/workflows/: GitHub Actions workflow definitionsbuild-readme.yml: Automatically rebuilds README when content changesupdate-structure.yml: Updates project structure documentation
-
docs/readme/: README template filesbase.md.j2: Main template filesections/: Individual section templates
-
src/readme_generator/: Core Python packagegenerators/: Generation componentstree_generator.py: Tree generation utilitiesreadme_generator.py: README generation logicstructure_generator.py: Structure documentation
utils.py: Shared utility functions__main__.py: CLI entry point
-
pyproject.toml: Project configuration and dependencies
- Add automatic table of contents generation
- Add module summary with function signatures
- Expand documentation with more examples
- Add API integration instructions
- Add more utility functions for common agent operations
- Create workflow templates for common agent tasks
- Add more reusable components
- Add GitHub Pages integration for project documentation
- Add more test cases for edge cases
- Add integration tests for workflows
- Improve test coverage