diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000000000000000000000000000000000000..40de38fa7ca39549fb5599f3931855af706aa561
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,48 @@
+# Basic style rules by Charles Lohr
+# Additions and modifications by Sam Ellicott
+#
+# For information about the definitions of rules
+# See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+
+BasedOnStyle: Microsoft
+AccessModifierOffset: -4
+
+# Basic general rules
+ColumnLimit: '120'
+TabWidth: 4
+UseTab: AlignWithSpaces 
+BreakBeforeBraces: Allman
+PointerAlignment: Right
+MaxEmptyLinesToKeep: 2
+IndentCaseLabels: true
+
+# Allignment rules
+AlignAfterOpenBracket: DontAlign
+AlignTrailingComments: false
+AlignConsecutiveAssignments: false
+AlignConsecutiveMacros: false
+AlignEscapedNewlines: Left
+AlignOperands: AlignAfterOperator
+
+# Rules for brackets/parentheses
+SpaceInEmptyParentheses: false
+SpacesInAngles: true
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: true
+SpacesInParentheses: true
+SpacesInSquareBrackets: false
+
+# Short statement rules
+AllowShortBlocksOnASingleLine: Never 
+AllowShortIfStatementsOnASingleLine: WithoutElse 
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+
+# Other Rules
+FixNamespaceComments: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AlwaysBreakTemplateDeclarations: 'Yes'
+BreakBeforeBinaryOperators: None
+BreakConstructorInitializers: BeforeComma
+ExperimentalAutoDetectBinPacking: false
+NamespaceIndentation: None
diff --git a/add_include.py b/.github/add_include.py
similarity index 100%
rename from add_include.py
rename to .github/add_include.py
diff --git a/platformio.ini b/platformio.ini
index 2da7e046764f462fbbd88db22cbd698f9bd912c4..b20948c308573b4c6a792953fa544b65c6b559c0 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -17,7 +17,7 @@ extends = fun_base
 board_build.ldscript = ch32v003fun/ch32v003fun.ld
 build_flags = -flto -Ich32v003fun -I/usr/include/newlib -lgcc -Iextralibs
 ; dynamically add "examples/$PIOENV" to the include path
-extra_scripts = add_include.py
+extra_scripts = .github/add_include.py
 build_src_filter = +<ch32v003fun>
 extra_libs_srcs = +<extralibs>