HOWTO: Open Source

How to set up a proper open source project that doesn’t become a maintenance nightmare. We’ll cover licensing, documentation, and security basics. Make your repo something people actually want to contribute to.

If you’ve decided that you want to have a public GitHub repository, there are several things you should do to make it a good open source project, and not a nightmare.

Repository Structure

A well-organized repository structure makes it easier for contributors to understand and navigate your project.

Standard Directories

DirectoryPurpose
src/ or lib/Source code files
docs/Documentation files
tests/ or spec/Test files
examples/Example usage of your project
scripts/Utility scripts for development, building, etc.
assets/Images, icons, and other static assets
.github/GitHub-specific files (workflows, templates)
dist/ or build/Compiled/built files (often git-ignored)
config/Configuration files

Essential Files

README.md

Your README is the first thing visitors see. A good README should include:

  • Project name and logo
  • Brief description of what the project does
  • Badges (build status, test coverage, version)
  • Installation instructions
  • Basic usage examples
  • Links to full documentation
  • License information
  • How to contribute

Example structure:

# Project Name

[![Build Status](https://img.shields.io/github/workflow/status/username/repo/CI)](https://github.com/username/repo/actions)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Version](https://img.shields.io/npm/v/package-name.svg)](https://npmjs.org/package/package-name)

Brief description of your project.

## Features

- Key feature 1
- Key feature 2
- Key feature 3

## Installation

```bash
npm install your-package-name
```

## Quick Start

```javascript
import { something } from 'your-package-name';

// Example code
```

## Documentation

For full documentation, visit [docs link].

## Contributing

Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.md).

## License

[MIT](LICENSE)

LICENSE

Always include a license file as LICENSE. Common open source licenses include:

  • MIT License (permissive) - allows anyone to use, modify, and distribute your code with minimal restrictions. This includes commercial use.
  • Apache License 2.0 (permissive with patent protection) - similar to MIT but includes an explicit grant of patent rights from contributors.
  • GNU GPL v3 (copyleft) - requires derivative works to also be open source under the same license. This is more restrictive and not suitable for commercial use without compliance.
  • BSD License (permissive) - similar to MIT but with clauses regarding the use of the name of the project or its contributors.

GitHub provides a license selector when creating repositories or you can add one later.

CONTRIBUTING.md

This file explains how others can contribute to your project:

  • Development environment setup
  • Coding conventions
  • Commit message format
  • Pull request process
  • How to report bugs
  • How to suggest features

To create a good contributing guide, see the GitHub guide on contributing.

CODE_OF_CONDUCT.md

A code of conduct defines community standards, signals a welcoming environment, and outlines procedures for handling abuse. The Contributor Covenant is a commonly used template.

You can get a Markdown version of this doc from the bottom of this page.

CHANGELOG.md

Track all notable changes between versions of your project. Format:

# Changelog

## [Unreleased]

## [1.0.0] - 2023-05-27

### Added
- New feature X

### Changed
- Improved performance of Y

### Fixed
- Bug in component Z

## [0.9.0] - 2023-04-15
...

SECURITY.md

Explain your security policy and how to report vulnerabilities.

SUPPORT.md

Information on where users can get help with your project.

STYLE_GUIDE.md

Document your coding standards and style conventions. Consider working with your Coding LLM to analyze your project, pull out patterns about how you code, and generate a style guide based on YOU.

Or, using your Coding LLM to generate an ideal, best-practices style guide. Then you can use that to analyze and level-up your code to that Standard.

GitHub Features Configuration

Issue Templates

Create templates for bug reports, feature requests, and other common issues in .github/ISSUE_TEMPLATE/.

Bug report template example:

---
name: Bug report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment:**
 - OS: [e.g. iOS]
 - Browser/Runtime: [e.g. chrome, node]
 - Version: [e.g. 22]

**Additional context**
Add any other context about the problem here.

Pull Request Template

Create a .github/PULL_REQUEST_TEMPLATE.md:

## Description
Clearly describe what changes this PR introduces and why.

## Related Issue(s)
Fixes #123

## Testing
Describe how you tested these changes.

## Checklist
- [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document
- [ ] My code follows the project's [STYLE_GUIDE](../STYLE_GUIDE.md)
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] I have updated the documentation accordingly
- [ ] I have added a changelog entry to [CHANGELOG.md](../CHANGELOG.md)

GitHub Workflows

Set up CI/CD workflows in .github/workflows/ to automate testing, linting, and deployment.

Basic CI workflow example (.github/workflows/ci.yml):

name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Set up runtime
      uses: actions/setup-node@v3
      with:
        node-version: 16
    - name: Install dependencies
      run: npm ci
    - name: Run tests
      run: npm test
    - name: Run linter
      run: npm run lint

Repository Settings to Configure

Branch Protection

Protect your main branch:

  • Require pull request reviews before merging
  • Require status checks to pass
  • Require linear history
  • Do not allow force pushes

Feature Toggles

Enable/disable these GitHub features based on your needs:

FeatureRecommendationRationale
IssuesEnableTracks bugs, enhancements, tasks
ProjectsEnable for larger projectsProject management
DiscussionsEnableCommunity conversation space
WikiEnable for comprehensive docsCollaborative documentation
SponsorshipOptionalFunding opportunities
PackagesOptionalFor published packages

Labels

Create a comprehensive set of labels for issues and PRs:

  • bug - Something isn’t working
  • documentation - Documentation improvements
  • enhancement - New features or improvements
  • good first issue - Good for newcomers
  • help wanted - Extra attention needed
  • question - Further information requested
  • wontfix - This won’t be worked on

Community Engagement Best Practices

  1. Respond promptly to issues and pull requests
  2. Acknowledge contributions and thank contributors
  3. Document versioning policy clearly
  4. Set expectations for maintenance and response times
  5. Create a roadmap to show future direction

Maintenance Tools

Consider these tools to help maintain your project:

  • Automated dependency updates (Dependabot, Renovate)
  • Code quality tools (SonarQube, Code Climate)
  • Test coverage (Codecov, Coveralls)
  • Semantic versioning for releases
  • Release automation scripts/workflows

Release Process

  1. Update version numbers in relevant files
  2. Update CHANGELOG.md with all notable changes
  3. Create release branch if using GitFlow
  4. Tag the release with the version number
  5. Create GitHub Release with compiled assets if applicable
  6. Publish to relevant package managers

Final Checklist Before Going Public

  • Proper LICENSE is included
  • README contains all essential information
  • Code of Conduct is established
  • Contributing guidelines are clear
  • Continuous Integration is set up
  • Repository structure is organized
  • Security policy is defined
  • Issue and PR templates are configured
  • Documentation is accessible and comprehensive
  • First release is tagged

By following these best practices, you’ll create a welcoming, well-structured open source project that’s easier to maintain and more likely to attract contributors.