Skip to content

Commit 56821d0

Browse files
authored
Merge pull request #22 from attogram/add-new-platforms
feat: Add comprehensive guides for multiple platforms
2 parents 1a7c8d6 + 7bed08a commit 56821d0

17 files changed

+1561
-3
lines changed

.repo/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This repository uses a specific structure to organize instructions. You must fam
2727

2828
- **`../agents/`**: Contains technical instructions for specific AI agent personas (the "who").
2929
- **`../humans/`**: Contains guides for humans on how to interact with the AI agent personas.
30+
- **`../personas/`**: Contains personality traits and profiles that agents can adopt (the "how").
3031
- **`../platforms/`**: Contains technical instructions for how agents should work with specific technologies (the "what").
3132

3233
## Your Task

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,23 @@ Standardize your AI collaboration.
4545

4646
## Platforms
4747

48-
- [Bash](./platforms/bash.md) - for Bash
49-
- [PHP](./platforms/php.md) - for PHP
50-
- [PHP with Laravel](./platforms/php.laravel.md) - for PHP with Laravel
48+
- [Bash](./platforms/bash.md)
49+
- [C++](./platforms/cpp.md)
50+
- [Docker](./platforms/docker.md)
51+
- [Go](./platforms/go.md)
52+
- [JavaScript](./platforms/javascript.md)
53+
- [Next.js](./platforms/javascript-nextjs.md)
54+
- [Node.js](./platforms/javascript-nodejs.md)
55+
- [React](./platforms/javascript-react.md)
56+
- [Vue.js](./platforms/javascript-vue.md)
57+
- [PHP](./platforms/php.md)
58+
- [Laravel](./platforms/php.laravel.md)
59+
- [WordPress](./platforms/php-wordpress.md)
60+
- [PostgreSQL](./platforms/postgresql.md)
61+
- [Python](./platforms/python.md)
62+
- [Django](./platforms/python-django.md)
63+
- [Rust](./platforms/rust.md)
64+
- [TypeScript](./platforms/typescript.md)
5165

5266
## Development
5367

platforms/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Platforms
2+
3+
- [Bash](./bash.md)
4+
- [C++](./cpp.md)
5+
- [Docker](./docker.md)
6+
- [Go](./go.md)
7+
- [JavaScript](./javascript.md)
8+
- [Next.js](./javascript-nextjs.md)
9+
- [Node.js](./javascript-nodejs.md)
10+
- [React](./javascript-react.md)
11+
- [Vue.js](./javascript-vue.md)
12+
- [PHP](./php.md)
13+
- [Laravel](./php.laravel.md)
14+
- [WordPress](./php-wordpress.md)
15+
- [PostgreSQL](./postgresql.md)
16+
- [Python](./python.md)
17+
- [Django](./python-django.md)
18+
- [Rust](./rust.md)
19+
- [TypeScript](./typescript.md)

platforms/cpp.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Working with C++
2+
3+
This document provides guidelines and best practices for AI agents working on C++ projects. The focus is on **Modern C++ (C++11 and newer)**, which introduced features that make the language safer, more expressive, and easier to use.
4+
5+
## 1. Development Environment
6+
7+
A C++ project requires a compiler, a build system, and often a package manager.
8+
9+
### Compilers
10+
11+
- **GCC (GNU Compiler Collection)**: The `g++` compiler is the standard on most Linux systems.
12+
- **Clang**: A modern compiler from the LLVM project, known for its excellent error messages.
13+
- **MSVC**: The Microsoft Visual C++ compiler, standard on Windows.
14+
15+
### Build Systems
16+
17+
**CMake** is the de-facto standard build system for modern C++ projects. It uses a script named `CMakeLists.txt` to define the build process.
18+
19+
- **`CMakeLists.txt`**: This file contains a set of directives and commands that describe the project's source files and dependencies.
20+
21+
- **Basic `CMakeLists.txt` Example**:
22+
23+
```cmake
24+
# Specify the minimum version of CMake required.
25+
cmake_minimum_required(VERSION 3.10)
26+
27+
# Set the project name and language.
28+
project(MyProject CXX)
29+
30+
# Specify the C++ standard.
31+
set(CMAKE_CXX_STANDARD 17)
32+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
33+
34+
# Add an executable target.
35+
add_executable(my_app main.cpp)
36+
```
37+
38+
- **Building with CMake**:
39+
```bash
40+
mkdir build
41+
cd build
42+
cmake ..
43+
make
44+
```
45+
46+
### Package Management
47+
48+
Managing dependencies in C++ can be complex. Package managers help automate this process.
49+
50+
- **vcpkg (Microsoft)**: A cross-platform package manager.
51+
- **Conan**: Another popular, cross-platform package manager.
52+
53+
## 2. Key Language Features (Modern C++)
54+
55+
### RAII and Smart Pointers
56+
57+
**RAII (Resource Acquisition Is Initialization)** is a core C++ principle. It means that you tie the life cycle of a resource (like memory, a file handle, or a network socket) to the lifetime of an object. The resource is acquired in the object's constructor and released in its destructor.
58+
59+
**Smart Pointers** are the primary way to implement RAII for memory management. They automatically handle memory deallocation, preventing memory leaks.
60+
61+
- `std::unique_ptr`: A smart pointer that owns and manages another object through a pointer and disposes of that object when the `unique_ptr` goes out of scope. There can only be one `unique_ptr` to an object.
62+
- `std::shared_ptr`: A smart pointer that retains shared ownership of an object through a pointer. Several `shared_ptr` objects may own the same object. The object is destroyed when the last remaining `shared_ptr` owning it is destroyed.
63+
- `std::weak_ptr`: A smart pointer that holds a non-owning ("weak") reference to an object that is managed by a `shared_ptr`. It is used to break circular references.
64+
65+
**Always prefer smart pointers over raw pointers (`new` and `delete`) for managing dynamic memory.**
66+
67+
### The Standard Template Library (STL)
68+
69+
The STL is a set of C++ template classes to provide common data structures and functions.
70+
71+
- **Containers**:
72+
- `std::vector`: A dynamic array.
73+
- `std::string`: A string class.
74+
- `std::map`: A key-value map (implemented as a red-black tree).
75+
- `std::unordered_map`: A key-value map (implemented as a hash table).
76+
- **Algorithms**: The `<algorithm>` header provides a rich set of functions for operating on ranges of elements (e.g., `std::sort`, `std::find`, `std::for_each`).
77+
78+
### Lambdas
79+
80+
Lambdas are a concise way to create anonymous functions.
81+
82+
```cpp
83+
#include <vector>
84+
#include <algorithm>
85+
#include <iostream>
86+
87+
int main() {
88+
std::vector<int> v = {1, 2, 3, 4, 5};
89+
std::for_each(v.begin(), v.end(), [](int n) {
90+
std::cout << n << std::endl;
91+
});
92+
return 0;
93+
}
94+
```
95+
96+
## 3. Testing
97+
98+
- **Google Test (`gtest`)**: A popular and powerful C++ testing framework. It provides a rich set of assertions and features for writing tests.
99+
- **Catch2**: Another popular, modern, and easy-to-use testing framework.
100+
101+
A typical test with Google Test looks like this:
102+
103+
```cpp
104+
#include "gtest/gtest.h"
105+
106+
int add(int a, int b) {
107+
return a + b;
108+
}
109+
110+
TEST(AddTest, PositiveNumbers) {
111+
EXPECT_EQ(add(2, 3), 5);
112+
}
113+
```

platforms/docker.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Working with Docker
2+
3+
This document provides guidelines and best practices for AI agents working with Docker. Docker is a fundamental tool for creating consistent, isolated, and portable development and production environments.
4+
5+
## 1. Core Concepts
6+
7+
A solid understanding of Docker's core concepts is essential.
8+
9+
- **Images**: A read-only template with instructions for creating a Docker container. Images are the blueprints of your application. They are built from a `Dockerfile`.
10+
- **Containers**: A runnable instance of an image. You can create, start, stop, move, or delete a container. Containers are isolated from one another and from the host machine.
11+
- **Dockerfile**: A text document that contains all the commands a user could call on the command line to assemble an image. `docker build` uses this file to create an image.
12+
- **Volumes**: The preferred mechanism for persisting data generated by and used by Docker containers. While bind mounts are dependent on the directory structure of the host machine, volumes are completely managed by Docker.
13+
- **Docker Hub / Registries**: A registry of Docker images. Docker Hub is the default public registry. You can pull images from a registry and push your own images to it.
14+
- **Docker Compose**: A tool for defining and running multi-container Docker applications. It uses a YAML file (`docker-compose.yml`) to configure the application's services.
15+
16+
## 2. Dockerfile Best Practices
17+
18+
Writing a clean, efficient, and secure `Dockerfile` is critical.
19+
20+
- **Use a `.dockerignore` file**: Exclude files and directories that are not necessary for the build, such as `.git`, `node_modules`, and temporary files. This reduces the build context size and improves build performance.
21+
- **Use Multi-Stage Builds**: Use multi-stage builds to separate the build environment from the final runtime environment. This dramatically reduces the size of your final image by excluding build-time dependencies and tools.
22+
23+
```dockerfile
24+
# Build stage
25+
FROM node:18 as builder
26+
WORKDIR /app
27+
COPY package.json .
28+
RUN npm install
29+
COPY . .
30+
RUN npm run build
31+
32+
# Final stage
33+
FROM nginx:stable-alpine
34+
COPY --from=builder /app/build /usr/share/nginx/html
35+
EXPOSE 80
36+
CMD ["nginx", "-g", "daemon off;"]
37+
```
38+
39+
- **Choose Minimal Base Images**: Start with a minimal base image, like `alpine`, to reduce the image size and attack surface.
40+
- **Don't Install Unnecessary Packages**: Avoid installing debugging tools or other packages that are not needed in the final image.
41+
- **Combine `RUN` instructions**: Chain `RUN` commands using `&&` to reduce the number of layers in your image. Clean up temporary files in the same layer.
42+
43+
```dockerfile
44+
RUN apt-get update && apt-get install -y \
45+
package-one \
46+
package-two \
47+
&& rm -rf /var/lib/apt/lists/*
48+
```
49+
50+
- **Leverage Build Cache**: Order your `Dockerfile` instructions from least to most frequently changing. `COPY package.json` and `RUN npm install` should come before `COPY . .` so that you don't have to re-install dependencies every time a source file changes.
51+
- **Run as a Non-Root User**: Create a non-root user and use the `USER` instruction to run your application. This is a crucial security best practice.
52+
53+
```dockerfile
54+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
55+
USER appuser
56+
```
57+
58+
## 3. Essential CLI Commands
59+
60+
You will frequently interact with the Docker daemon via the CLI.
61+
62+
### Single Container Management
63+
64+
- `docker build -t <image-name>:<tag> .`: Build an image from a Dockerfile.
65+
- `docker run [OPTIONS] <image-name>`: Run a container from an image.
66+
- `-d`: Detached mode (run in the background).
67+
- `-p <host-port>:<container-port>`: Map a port.
68+
- `--rm`: Automatically remove the container when it exits.
69+
- `-v <volume-name>:<container-path>`: Mount a volume.
70+
- `--name <container-name>`: Assign a name to the container.
71+
- `docker ps`: List running containers. (`-a` to show all).
72+
- `docker stop <container-id|name>`: Stop a running container.
73+
- `docker rm <container-id|name>`: Remove a stopped container.
74+
- `docker logs <container-id|name>`: View the logs of a container.
75+
- `docker exec -it <container-id|name> <command>`: Execute a command in a running container (e.g., `bash`).
76+
- `docker images`: List all images on the system.
77+
- `docker rmi <image-id>`: Remove an image.
78+
- `docker pull <image-name>:<tag>`: Pull an image from a registry.
79+
- `docker push <image-name>:<tag>`: Push an image to a registry.
80+
81+
### Multi-Container Management (Docker Compose)
82+
83+
- `docker-compose up`: Build, (re)create, start, and attach to containers for a service. Use `-d` to run in detached mode.
84+
- `docker-compose down`: Stop and remove containers, networks, images, and volumes. Use `-v` to remove named volumes.
85+
- `docker-compose ps`: List containers.
86+
- `docker-compose logs`: View logs from services.
87+
- `docker-compose build`: Build or rebuild services.
88+
- `docker-compose exec <service-name> <command>`: Execute a command in a running service.
89+
90+
## 4. Security Best Practices
91+
92+
- **Principle of Least Privilege**:
93+
- Always run containers as a non-root user (`USER` instruction).
94+
- Use `COPY` instead of `ADD` where possible, as `ADD` can have unexpected behavior (e.g., auto-extracting tarballs).
95+
- **Reduce Attack Surface**:
96+
- Use minimal base images.
97+
- Don't install unnecessary packages.
98+
- Use multi-stage builds to discard build tools.
99+
- **Scan for Vulnerabilities**: Use tools like Docker Scout, Trivy, or Snyk to scan your images for known vulnerabilities.
100+
- **Manage Secrets Securely**:
101+
- Do not copy secrets (API keys, passwords) directly into your `Dockerfile`.
102+
- Use build-time secrets (`--secret`) or runtime environment variables/Docker secrets to handle sensitive data.
103+
- **Prevent Privilege Escalation**: Run containers with `--security-opt=no-new-privileges` to prevent processes from gaining new privileges.

platforms/go.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Working with Go
2+
3+
This document provides guidelines and best practices for AI agents working on Go projects. Go is a statically typed, compiled language known for its simplicity, performance, and excellent support for concurrent programming.
4+
5+
## 1. Development Environment
6+
7+
Go has a strong focus on tooling and a standardized project structure.
8+
9+
### Go Modules
10+
11+
Modern Go projects use Go Modules to manage dependencies. A project is defined as a module, and it's declared with a `go.mod` file in the project's root directory.
12+
13+
- **`go.mod`**: This file defines the module's path (its name), the version of Go it was built with, and its dependencies.
14+
- **`go.sum`**: This file contains the checksums of the direct and indirect dependencies to ensure reproducible builds. It is automatically generated and updated.
15+
16+
### The `go` command
17+
18+
The `go` command is the main entry point for a suite of tools.
19+
20+
- `go run <file.go>`: Compiles and runs a Go program.
21+
- `go build`: Compiles the packages and their dependencies.
22+
- `go test`: Runs tests.
23+
- `go fmt`: Formats Go source code according to the language's conventions. This should be run frequently.
24+
- `go get <package>`: Adds a new dependency to the current module.
25+
- `go mod tidy`: Ensures the `go.mod` file matches the source code's dependencies, adding any missing ones and removing unused ones.
26+
27+
## 2. Basic Syntax
28+
29+
- **Packages**: Every Go program is made up of packages. The `main` package is the entry point for an executable program.
30+
- **Variables**:
31+
- `var name string = "Jules"`: Declares a variable with its type.
32+
- `name := "Jules"`: The `:=` syntax is shorthand for declaring and initializing a variable. Go infers the type.
33+
- **Structs**: A `struct` is a collection of fields. It's used to group data together.
34+
```go
35+
type User struct {
36+
ID int
37+
Name string
38+
}
39+
```
40+
- **Functions**: Functions can take zero or more arguments and can return multiple values.
41+
```go
42+
func add(a int, b int) int {
43+
return a + b
44+
}
45+
```
46+
47+
## 3. Key Language Features
48+
49+
### Concurrency (Goroutines and Channels)
50+
51+
Go's approach to concurrency is one of its most powerful features.
52+
53+
- **Goroutines**: A goroutine is a lightweight thread managed by the Go runtime. You can start a new goroutine with the `go` keyword.
54+
```go
55+
go myFunction() // This will run myFunction concurrently.
56+
```
57+
- **Channels**: Channels are a typed conduit through which you can send and receive values with the channel operator, `<-`. They are the primary way to communicate between goroutines.
58+
59+
```go
60+
messages := make(chan string)
61+
62+
go func() { messages <- "ping" }()
63+
64+
msg := <-messages
65+
fmt.Println(msg) // "ping"
66+
```
67+
68+
### Interfaces
69+
70+
Interfaces in Go provide a way to specify the behavior of an object. An interface is a collection of method signatures. A type implements an interface by implementing its methods. There is no `implements` keyword; the implementation is implicit.
71+
72+
```go
73+
type Shape interface {
74+
Area() float64
75+
}
76+
```
77+
78+
### Error Handling
79+
80+
Go has a simple, idiomatic approach to error handling. Functions that can fail return an `error` value as their last return value.
81+
82+
```go
83+
f, err := os.Open("filename.ext")
84+
if err != nil {
85+
log.Fatal(err)
86+
}
87+
// do something with the file f
88+
```
89+
90+
## 4. Testing
91+
92+
Go has a built-in testing framework provided by the `testing` package.
93+
94+
- Test files are named `*_test.go`.
95+
- Test functions are named `TestXxx` (where `Xxx` does not start with a lowercase letter) and take `*testing.T` as a parameter.
96+
- You run tests with the `go test` command.
97+
98+
```go
99+
// main_test.go
100+
package main
101+
102+
import "testing"
103+
104+
func TestAdd(t *testing.T) {
105+
if add(2, 3) != 5 {
106+
t.Errorf("add(2, 3) = %d; want 5", add(2, 3))
107+
}
108+
}
109+
```
110+
111+
## 5. Standard Library
112+
113+
Go has a rich standard library that provides many useful packages. Key packages include:
114+
115+
- `fmt`: For formatted I/O.
116+
- `net/http`: For building HTTP clients and servers.
117+
- `encoding/json`: For encoding and decoding JSON.
118+
- `os`: For operating system-level operations.
119+
- `io`: For I/O primitives.

0 commit comments

Comments
 (0)