Skylark is the code name of the extension mechanism for Bazel. It lets you write custom build rules as well as compose existing ones into macros.
Read the concepts behind Skylark and try the cookbook examples. To go further, read about the standard library.